Repository navigation
[popups] Fix non-modal focus-out close and tabindex management - #5030
Conversation
- Reset isPointerDownRef after a click-trigger pointerdown so focus-out
closing isn't permanently suppressed (B1).
- Mark data-tabindex when writing tabindex=0 so the popup can be downgraded
back to -1 once content becomes tabbable (B2).
- Reset pointerDownOutsideRef on effect teardown so a stale value doesn't
leak into a keep-mounted popup's next open (B3).
- Add a closeOnFocusOut={false} regression test.
commit: |
Bundle size
PerformanceTotal duration: 1,214.45 ms +63.66 ms(+5.5%) | Renders: 50 (+0) | Paint: 1,851.29 ms +99.18 ms(+5.7%)
10 tests within noise — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Fixes several focus-management edge cases in FloatingFocusManager (shared by popups like Dialog/Popover/Menu) that could incorrectly suppress focus-out closing or leave tabindex management in a stuck state, especially for non-modal and keep-mounted popups.
Changes:
- Ensure
isPointerDownRefis reset after clicking a nested[data-base-ui-click-trigger]element so future focus-out closes aren’t suppressed. - Mark
data-tabindexwhen the manager setstabindex="0"to avoid misclassifying the value as user-authored and freezing later tabIndex updates. - Reset
pointerDownOutsideRefon interaction-tracking effect teardown to prevent stale state across keep-mounted reopen cycles. - Add regression tests covering
closeOnFocusOut={false}, nested click-trigger interactions, and managedtabIndexdowngrading when tabbable content appears.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react/src/floating-ui-react/components/FloatingFocusManager.tsx | Fixes pointer/focus state reset and ensures internal tabindex writes are properly marked for continued management. |
| packages/react/src/floating-ui-react/components/FloatingFocusManager.test.tsx | Adds regression tests for non-modal focus-out behavior, nested click-trigger behavior, and tabindex management transitions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Three focus-management fixes in
FloatingFocusManager(the shared focus manager used by Dialog, Popover, Menu, etc.):isPointerDownRefafter a click-trigger pointerdown. It was set when pointerdown landed on a[data-base-ui-click-trigger]element but only ever reset by the Safari workaround on the reference, so clicking a nested click-trigger inside a non-modal popup permanently suppressed every later focus-out close for the lifetime of the instance (and across sessions for keep-mounted popups).data-tabindexwhen writingtabindex="0". The empty-content branch ofhandleTabIndexwrotetabindex="0"without the marker, so the externally-managed early-return then treated our own write as user-authored and could never downgrade the container back to-1once content became tabbable.pointerDownOutsideRefon effect teardown so a staletruedoesn't leak into a keep-mounted popup's next open.Adds a
closeOnFocusOut={false}regression test.