Skip to content

test(menu): cover controlled external toggles outside Vue - #165

Merged
elonehoo merged 1 commit into
mainfrom
cursor/controlled-menu-external-toggle-f4db
Nov 1, 2026
Merged

elonehoo merged 1 commit into
mainfrom
cursor/controlled-menu-external-toggle-f4db

Conversation

@elonehoo

@elonehoo elonehoo commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

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 preventDefault makes the new test fail in each framework. The menu opens, the deferred document pointerdown listener is installed, then pointerdown and focus on the external button set the trigger to data-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.body still dismisses the menu.

Tests

  • packages/react/src/components/menu/test/controlled-outside.unit.test.tsx
  • packages/solid/src/components/menu/test/controlled-outside.unit.test.tsx
  • packages/svelte/src/lib/components/menu/test/controlled-outside.unit.test.ts

These run in happy-dom unit projects alongside Vue's controlled-outside.unit.test.ts. Browser regressions for the same examples remain in the shared checkControlledMenu helper.

Fixes #152.

Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with 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.

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>
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
destyler-ui Ready Ready Preview Oct 29, 2026 2:02am UTC
destyler-ui-dev Ready Ready Preview Oct 29, 2026 2:02am UTC

@elonehoo
elonehoo merged commit 4c82e37 into main Nov 1, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify and align Controlled Menu external-toggle examples across frameworks

2 participants