Repository navigation
test(menu): cover controlled external toggles outside Vue - #165
Merged
Merged
Conversation
Add the happy-dom regressions from the Vue controlled Menu example to React, Solid, and Svelte. Outside pointerdown or focus on the external toggle must not dismiss the open menu before its click closes it, and unrelated outside presses still dismiss. Co-authored-by: Elone Hoo <hi@elonehoo.me>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #152.
Vue's controlled Menu example coordinates its external toggle through
onInteractOutside/preventDefault, so pointerdown or focus cannot dismiss the menu before that button's click toggles it. The React, Solid, and Svelte examples already follow that pattern. This adds the happy-dom regressions that Vue gained in #63, without changing core.Reproduction
Removing
preventDefaultmakes the new test fail in each framework. The menu opens, the deferred documentpointerdownlistener is installed, then pointerdown and focus on the external button set the trigger todata-state="closed"before click. That is the race: the later click toggles the controlled value back open.With the existing coordination restored, the menu stays open through pointerdown and focus, the click closes it, and it stays closed across two cycles. A pointerdown on
document.bodystill dismisses the menu.Tests
packages/react/src/components/menu/test/controlled-outside.unit.test.tsxpackages/solid/src/components/menu/test/controlled-outside.unit.test.tsxpackages/svelte/src/lib/components/menu/test/controlled-outside.unit.test.tsThese run in happy-dom unit projects alongside Vue's
controlled-outside.unit.test.ts. Browser regressions for the same examples remain in the sharedcheckControlledMenuhelper.Fixes #152.
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Test-only and CI wiring changes; no production Menu or core logic is modified.
Reviewed by Cursor Bugbot for commit 5de6de8. Bugbot is set up for automated code reviews on this repo. Configure here.