fix: Close language selector dropdown on selection or outside click#3528
Open
abbyoung wants to merge 1 commit into
Open
fix: Close language selector dropdown on selection or outside click#3528abbyoung wants to merge 1 commit into
abbyoung wants to merge 1 commit into
Conversation
Close the language selector menu when a language option is selected or the user clicks outside the selector. Add coverage for display language labels and closing behavior. closes: #3170
Contributor
2 tasks
brandonlenz
approved these changes
Jul 8, 2026
brandonlenz
left a comment
Contributor
There was a problem hiding this comment.
This looks good to me! A couple of minor things I'd normally recommend for this PR, but since I found enough (unrelated) stuff to build out #3534, I think this is good to go!
We can merge #3534 into this PR before merging this to main, or merge it directly to main after. Your call, I'd love eyes/gut check on that PR though either way, if you have a chance.
Comment on lines
+70
to
+73
| document.addEventListener('click', closeOnOutsideClick) | ||
|
|
||
| return () => { | ||
| document.removeEventListener('click', closeOnOutsideClick) |
Contributor
There was a problem hiding this comment.
We probably want to add { capture: true } for these.
Done in #3534
| <LanguageSelector langs={localLanguagesButton} label="Languages" /> | ||
| ) | ||
|
|
||
| fireEvent.click(getByTestId('languageSelectorButton')) |
Contributor
There was a problem hiding this comment.
I think its worth swapping the test over to userEvent.
Done in #3534
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
❗Note to reviewers: Code in this PR was written using Codex.
Fixes a bug in the language selector dropdown menu that's used when more than two languages are present.
Related Issues or PRs
Closes #3170
How To Test
yarn storybookMoreThanTwoLanguagesAsALinkand confirm behaviorLanguagelink > click outside the menu. It should close.Languagelink > click a language. You will be redirected (existing behavior).Languagelink again > click a language > Confirm the menu closes as expected.MoreThan Two LanguagesAsAButtonand confirm behaviorLanguagelink > click outside the menu. It should close.Languagelink > click a language > menu should close.Custom Classand confirm behavior.Languagelink > click outside the menu. It should close.Languagelink > click a language > menu should close.Screenshots (optional)
Author & Maintainer checklist