Skip to content

[menu][combobox] Pass the originating event to onItemHighlighted - #5838

Merged
atomiks merged 4 commits into
mui:masterfrom
atomiks:highlight-event
Oct 2, 2026
Merged

atomiks merged 4 commits into
mui:masterfrom
atomiks:highlight-event

Conversation

@atomiks

@atomiks atomiks commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

onItemHighlighted in Menu and Combobox always received a placeholder new Event('base-ui'), even though the types map 'keyboard' to KeyboardEvent and 'pointer' to PointerEvent. After ArrowDown, details.event.key was undefined and details.event.getModifierState() threw.

This PR passes the originating native event through for keyboard and pointer highlights (arrow keys, typeahead, hover, chip removal, and the filterable menu's input and submenu keys). Highlights without an originating event keep the placeholder, which matches their Event type. The public highlight event types now accept MouseEvent | PointerEvent for the 'pointer' reason: hover supplies a mouse event, while leaving an item supplies a pointer event. This override is scoped to highlight notifications; the shared pointer-event mapping is unchanged.

Every reason is now derived from the event that caused it, so a 'keyboard' reason always carries a KeyboardEvent. Combobox drops its last-used-input flag, so clearing the highlight by typing or with Combobox.Clear now reports 'none' instead of 'keyboard'/'pointer', and hovering after keyboard navigation reports 'pointer'. Opening a filterable submenu with Enter or Space also reports 'none', since its click carries no key.

Note: preventDefault() and stopPropagation() called inside onItemHighlighted may now take effect, because discrete-event updates flush before the keydown finishes dispatching.

@atomiks atomiks added type: bug It doesn't behave as expected. component: combobox Changes related to the combobox component. labels Oct 1, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

commit: f716533

@code-infra-dashboard

code-infra-dashboard Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+6B(0.00%) 🔺+2B(0.00%)

Details of bundle changes

Performance

Total duration: 397.63 ms ▼-138.88 ms(-25.9%) | Renders: 76 (+0) | Paint: 718.52 ms ▼-267.77 ms(-27.1%)

Test Duration Renders
Tabs mount (200 instances) 63.75 ms ▼-29.14 ms(-31.4%) 3 (+0)
Select mount (200 instances) 52.27 ms ▼-15.86 ms(-23.3%) 3 (+0)
Select open (500 options) 23.78 ms ▼-15.58 ms(-39.6%) 14 (+0)
Menu mount (300 instances) 20.08 ms ▼-12.54 ms(-38.4%) 1 (+0)
Menu open (500 items) 18.03 ms ▼-10.58 ms(-37.0%) 11 (+0)

…and 6 more (+4 within noise) — details


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

@netlify

netlify Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f716533
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6abf8ddf43332800088a4360
😎 Deploy Preview https://deploy-preview-5838--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 marked this pull request as ready for review October 2, 2026 04:18
@atomiks atomiks added the component: menu Changes related to the menu component. label Oct 2, 2026
@atomiks
atomiks merged commit ca5b43f into mui:master Oct 2, 2026
25 checks passed
@atomiks
atomiks deleted the highlight-event branch October 2, 2026 11:05
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. component: menu Changes related to the menu component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant