Skip to content

feat(popup-menu): exempt an external element from outside press - #525

Merged
kianbazza merged 1 commit into
ui-554-forward-key-presses-into-a-menu-from-outsidefrom
ui-555-exempt-an-external-element-from-outside-press
Sep 29, 2026
Merged

kianbazza merged 1 commit into
ui-554-forward-key-presses-into-a-menu-from-outsidefrom
ui-555-exempt-an-external-element-from-outside-press

Conversation

@kianbazza

@kianbazza kianbazza commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

usePopupMenuRoot accepts getDismissExemptElements: elements outside the menu that don't dismiss it when pressed or when focus moves to them. The suggestion menu passes its host input, so clicking the field doesn't close its menu.

Two mechanisms dismiss a menu, and both respect the exemption:

our document pointerdown listener   -> a press inside an exempt element counts as inside
Base UI's dismissal (handleOpenChange)
  outside-press                     -> ignored when event.target is exempt
  focus-out                         -> ignored when relatedTarget (the element gaining focus) is exempt

Evidence

New use-popup-menu-root.outside-press.test.tsx:

  • Pressing the exempt input keeps the menu open. Removing either of the two checks makes this fail, so both mechanisms fire.
  • Pressing anything else still closes it, as does pressing the input when it isn't exempt.
  • Focus moving to the input keeps the menu open. Focus leaving the input for another element closes it.

Merge Danger

Door: two-way

Blast Radius: none

No member passes exempt elements yet.

Closes UI-555

@kianbazza
kianbazza added this pull request to stack #526 September 28, 2026 22:53
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ui-canary Ready Ready Preview Sep 29, 2026 2:31pm UTC

Request Review

@linear-code

linear-code Bot commented Sep 28, 2026

Copy link
Copy Markdown

UI-555

@kianbazza
kianbazza force-pushed the ui-555-exempt-an-external-element-from-outside-press branch from e79db15 to 02dd46c Compare September 29, 2026 14:29
@kianbazza
kianbazza marked this pull request as ready for review September 29, 2026 14:45
@kianbazza
kianbazza merged commit 7875400 into canary Sep 29, 2026
6 of 8 checks passed

This branch was successfully deployed

1 active deployment
Preview – ui-canary — 02dd46c0 Deployed Sep 29, 2026 by vercel[bot]
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.

1 participant