Repository navigation
[menu] Forward native event on item press close - #5789
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,136.10 ms -19.82 ms(-1.7%) | Renders: 76 (+0) | Paint: 1,835.85 ms -58.32 ms(-3.1%)
12 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
PR reviewNothing blocks merge. There is one narrow regression: a touch item press now hits MenuRoot's delayed-tap guard. I reproduced it with real touch taps in Chromium (CDP) and checked that master closes the menu in the same flow. Bugs (1)1. 🟠 Touch item press can leave the menu open after a focus-openLocation: nextOpen === false &&
nativeEvent?.type === 'click' &&
(nativeEvent as PointerEvent).pointerType === 'touch' &&
!allowTouchToCloseRef.currentThe native Failure scenario: In a Menubar with a menu open, press ArrowRight to open the next menu (keyboard + touchscreen), then tap an item within ~280 ms. The item's Fix: Add VerdictApprove after nits - the only finding is a narrow mixed-input regression with a one-line fix. 🤖 Review generated with Claude Code |
Problem
When a Menu item press closed the menu, the item's
onClickemitted the React synthetic event as the close event.FloatingFocusManagerclassifies the close interaction withinstanceof MouseEvent, which a synthetic event never passes. As a result,finalFocuscallbacks always received''instead of'keyboard'or'mouse', and keyboard selection never restoredfocus-visibleon the trigger.Solution
Emit
event.nativeEventinstead. The keyboard-click check inMenuRoot(detail === 0) reads the same value from the native event, so it behaves as before.The drag-release selection (press the trigger, drag onto an item, release) dispatches a synthesized
PointerEventclick with an emptypointerType, which would now be classified as'keyboard'.dispatchClickWithModifiersaccepts apointerTypeoption, and the drag-release path passes'mouse'.Added
MenuPopuptests assertingfinalFocusreceives'mouse'after a pointer click and after a drag-release selection, and'keyboard'after selecting an item with Enter.