[select] Fix Select not respecting shouldDismissPopover={false} on Enter#8096
Open
dokson wants to merge 3 commits into
Open
[select] Fix Select not respecting shouldDismissPopover={false} on Enter#8096dokson wants to merge 3 commits into
dokson wants to merge 3 commits into
Conversation
When a MenuItem is selected via keyboard (Enter), event.target is the
input element rather than the menu item, so the existing closest()
lookup returned null and the popover always dismissed. Fall back to the
active menu item in the document when the event target is not inside a
menu item, so `shouldDismissPopover={false}` is respected for both click
and keyboard selection.
Fixes palantir#8079
Member
|
Thanks for your interest in palantir/blueprint, @dokson! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
Generate changelog in
|
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
Fixes #8079.
When a
MenuItemis selected via keyboard (Enter),event.targetis the<input>element rather than the menu item. The existingtarget.closest('.bp6-menu-item')therefore returnednull, the dismiss check fell back to its default oftrue, and the popover always closed — ignoringshouldDismissPopover={false}.This change adds a fallback in
Select.handleItemSelectthat looks up the active menu item (.bp6-menu-item.bp6-active) when the event target is not inside a menu item, soshouldDismissPopoveris respected in both click and keyboard flows.Reproduction from the issue: https://codesandbox.io/p/devbox/exciting-payne-swcdjy
Test plan
select.test.tsxsuite passes (165 tests)Enteron the input, assert popover stays open whenshouldDismissPopover={false}