Skip to content

[select] Fix Select not respecting shouldDismissPopover={false} on Enter#8096

Open
dokson wants to merge 3 commits into
palantir:developfrom
dokson:ac/fix-select-enter-shoulddismisspopover
Open

[select] Fix Select not respecting shouldDismissPopover={false} on Enter#8096
dokson wants to merge 3 commits into
palantir:developfrom
dokson:ac/fix-select-enter-shoulddismisspopover

Conversation

@dokson
Copy link
Copy Markdown

@dokson dokson commented May 3, 2026

Summary

Fixes #8079.

When a MenuItem is selected via keyboard (Enter), event.target is the <input> element rather than the menu item. The existing target.closest('.bp6-menu-item') therefore returned null, the dismiss check fell back to its default of true, and the popover always closed — ignoring shouldDismissPopover={false}.

This change adds a fallback in Select.handleItemSelect that looks up the active menu item (.bp6-menu-item.bp6-active) when the event target is not inside a menu item, so shouldDismissPopover is respected in both click and keyboard flows.

Reproduction from the issue: https://codesandbox.io/p/devbox/exciting-payne-swcdjy

Test plan

  • Existing select.test.tsx suite passes (165 tests)
  • New regression test: simulate keydown+keyup Enter on the input, assert popover stays open when shouldDismissPopover={false}

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
@palantirtech
Copy link
Copy Markdown
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.

@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented May 3, 2026

Generate changelog in packages/select/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[select] Fix Select not respecting shouldDismissPopover={false} on Enter

Check the box to generate changelog(s)

  • Generate changelog entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select MenuItems dont respect shouldDismissPopover={false} when selected with Enter

2 participants