Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LF-4056b Fix for language selector dropdown #3436

Merged

Conversation

kathyavini
Copy link
Collaborator

@kathyavini kathyavini commented Sep 12, 2024

Description

When I migrated to the new useLanguageOptions hook in this PR:

I completely missed that components/Profile/Account expected to see the options in a map format, not in the React Select Options array format expected by components/InviteUser and components/Profile/EditUser.

The hook only returns the array shape, so the code that sets the languagePreferenceOptionRef no longer created the correct React Select option shape, and as a result the language became unselected when you saved a new language_preference.

I also considered updating the hook to return either map or array depending on the calling component (i.e. to accept a parameter like returnType = 'map' | 'array', but I thought it seemed cleaner to update the account code to work with the options array as the other two components do.

Also in this PR:

  • There was a 100ms nulling of the selected language upon change which flashes the unselected state (you can still see it on app) -- maybe this had a purpose at some point (giving translations time to load or such maybe, according to comment?) but I certainly didn't see such a purpose now so I have deleted it. Therefore no more flash.
  • I forgot to delete the t() function from the useLanguageOptions hook when I updated the language dropdown options in LF-4056 Language selector needs to provide list of language in their native form #3416 (at which point they are no longer sent through i18n)

Jira link: https://lite-farm.atlassian.net/browse/LF-4056?focusedCommentId=17638 (linking to comment describing the bug)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

Maybe it was necessary when the strings were translated? But now I don't see it doing anything other than flashing a null value before selection; very unpleasant
@kathyavini kathyavini self-assigned this Sep 12, 2024
@kathyavini kathyavini requested review from a team as code owners September 12, 2024 18:08
@kathyavini kathyavini requested review from Duncan-Brain and removed request for a team September 12, 2024 18:08
@kathyavini kathyavini added the bug Something isn't working label Sep 12, 2024
@kathyavini kathyavini merged commit 023db99 into patch/translations Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants