fix(spx-gui): defer dropdown outside click binding#3063
Conversation
There was a problem hiding this comment.
Code Review
This pull request changes the UIDropdown component to use the mouseup event instead of click for detecting outside clicks, intended to fix timing issues with manual control. However, the review feedback points out that this change introduces significant issues, including broken accessibility for keyboard users, unexpected closures during text selection (drag-out), and potential conflicts if the dropdown is opened on mousedown. It is recommended to revert to the click event and address the timing issue using a setTimeout or by checking event timestamps.
This comment was marked as resolved.
This comment was marked as resolved.
|
The deferred-binding approach is cleaner than the previous
|
There was a problem hiding this comment.
Pull request overview
This PR adjusts UIDropdown’s outside-close behavior to avoid immediately closing when the dropdown is opened via a mouseup-driven manual control flow, and updates tests to cover the timing regression.
Changes:
- Defer binding the document
clickoutside-close listener to the next macrotask (timeout(0)) and guard against binding after effect cleanup viagetCleanupSignal(onCleanup). - Switch dropdown outside-close tests back to
click-based behavior and add a regression test for manualmouseupopen. - Update test flushing to advance timers to accommodate the deferred listener binding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| spx-gui/src/components/ui/UIDropdown.vue | Defers outside-click listener binding and uses cleanup abort signals to prevent late bindings. |
| spx-gui/src/components/ui/UIDropdown.test.ts | Adjusts flush helper for timers and adds a regression test for mouseup-opened manual dropdowns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
clicktimeout(0)so the opening interaction is not treated as an outside clickgetCleanupSignal(onCleanup)to avoid binding listeners after the effect is cleaned upclick-based outside-close tests and add a regression test for manualmouseupopenValidation