Skip to content

[combobox] Keep portalled popup content open - #5334

Merged
atomiks merged 4 commits into
mui:masterfrom
obeattie:combobox-popup-portal-close
Jul 27, 2026
Merged

atomiks merged 4 commits into
mui:masterfrom
obeattie:combobox-popup-portal-close

Conversation

@obeattie

@obeattie obeattie commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Combobox previously attached its dismissal handlers to Combobox.List. As a result, React descendants rendered through a portal from elsewhere inside Combobox.Popup could be treated as outside the Combobox and close it when interacted with. This was noticeable when rendering a nested Popover beside the list.

This change attaches the dismissal handlers to Combobox.Popup, matching Select’s behavior, while keeping list navigation handlers on Combobox.List. This ensures portalled controls do not accidentally handle Combobox navigation keys. Regression tests cover both the dismissal behavior and arrow-key handling, along with the equivalent behavior in Select.

Here's the same example code from the ticket on top of a patched base-ui, which works: https://codesandbox.io/p/devbox/base-ui-combobox-portal-bug-forked-qvprr3

Fixes #5333.

@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5334
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5334
    

commit: c1adcac

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+99B(+0.02%) 🔺+33B(+0.02%)

Details of bundle changes

Performance

Total duration: 1,101.32 ms -18.90 ms(-1.7%) | Renders: 78 (+0) | Paint: 1,726.02 ms -21.78 ms(-1.2%)

Test Duration Renders
Scroll Area mount (300 instances) 72.82 ms 🔺+13.68 ms(+23.1%) 3 (+0)

14 tests within noise — details

Metric alarms

Test Metric Change
Scroll Area mount (300 instances) bench:paint 🔺 +15.32 ms

Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit c1adcac
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a673f1881bcc60008de2262
😎 Deploy Preview https://deploy-preview-5334--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks

atomiks commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

PR review

No merge-blocking regression. The new Popup/List ownership split leaves a pre-existing modal focus bug in place, but this PR provides a natural and very small place to correct it.

Bugs (1)

1. ℹ️ Move the focus-manager marker to Popup

Location: packages/react/src/combobox/root/AriaCombobox.tsx:1242

const listProps = React.useMemo(
  () => mergeProps(FOCUSABLE_POPUP_PROPS, listNavigation.floating, role.floating),
  [listNavigation.floating, role.floating],
);

FOCUSABLE_POPUP_PROPS adds tabIndex={-1} and data-base-ui-focusable. The latter tells FloatingFocusManager which descendant of the Positioner contains the popup’s tabbable content. Keeping it on List restricts modal focus cycling to the List and excludes the Input and other controls inside Popup.

This behavior already exists on master, so it is not a regression introduced here. However, now that dismissal ownership is moving to Popup while navigation remains on List, focus ownership should be split at the same boundary.

Failure scenario: Render a modal Combobox with Input, List, and a sibling button inside Popup. After tabbing from Input to the button, the next Tab leaves focus on the hidden focus guard instead of wrapping to Input.

Fix: Apply FOCUSABLE_POPUP_PROPS to Combobox.Popup, remove its duplicate explicit tabIndex: -1, and remove the constant from listProps. Keep List’s existing explicit tabIndex: -1 together with its navigation and role props. Popup-less inline mode remains supported because List is then the Floating UI element itself.

Verdict

Approve - the focus issue is pre-existing, though this ownership refactor is the cleanest place to address it.


🤖 Review generated with Codex

@obeattie
obeattie force-pushed the combobox-popup-portal-close branch from efdb235 to 8e08886 Compare July 27, 2026 09:55
@obeattie

Copy link
Copy Markdown
Contributor Author

@atomiks Thanks for taking a look. I've addressed what Codex mentioned.

FOCUSABLE_POPUP_PROPS now lives on Combobox.Popup, while Combobox.List retains only its navigation and role props.

(The failing browser test looks like an unrelated flake.)

@atomiks atomiks added type: bug It doesn't behave as expected. component: combobox Changes related to the combobox component. labels Jul 27, 2026
@atomiks

atomiks commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@obeattie thanks for the fix!

The info point Codex posted above was a thought I personally had when looking at the diff, I got it to investigate to format it and post for review. In the process it found the modal bug

(The failing browser test looks like an unrelated flake.)

Yes unfortunately these have been popping up quite a bit, need to look into it.

@atomiks
atomiks merged commit f17f2ef into mui:master Jul 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: combobox Changes related to the combobox component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[combobox] Portalled content inside Popup can close the Combobox

2 participants