Repository navigation
[menu] Fix event listener cleanup in MenuTrigger component - #5764
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,027.50 ms -168.62 ms(-14.1%) | Renders: 76 (+0) | Paint: 1,723.51 ms -258.38 ms(-13.0%)
11 tests within noise — details Check out the code infra dashboard for more information about this PR. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cleanup can be skipped after the open reason changes, leaving a stale listener attached.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds cleanup for the document-level mouseup listener used by hover-opened menu triggers.
Changes:
- Removes the listener when the effect cleans up.
| File | Description |
|---|---|
packages/react/src/menu/trigger/MenuTrigger.tsx |
Adds document listener cleanup logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ize-neutral
- Drop `usePressReleaseListener`. Menu and Context Menu keep their own
listeners, Select and Combobox keep `{ once: true }`, and Menu's mui#5764
test is back.
- `isPressReleasedInside(event, trigger, positioner, list?)` takes
positional args and uses the trigger for the bounds check. Menu walks
the menu tree itself, so `findRootOwnerId` stays in `menu/utils`.
- Context Menu's unmount cleanup test now waits out the long-press window
before unmounting, so it fails without the cleanup.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

This is the 5th PR in react-doctor series. Previous PR's #5760 #5761
This PR adds missing clean up function in useEffect