Skip to content

fix(DismissibleLayer): close layers on rapid outside pointerdowns (#1743) - #2229

Merged
huntabyte merged 1 commit into
mainfrom
fix/1743-rapid-outside-interaction
Oct 20, 2026
Merged

huntabyte merged 1 commit into
mainfrom
fix/1743-rapid-outside-interaction

Conversation

@huntabyte

Copy link
Copy Markdown
Owner

Summary

  • Fixes Quickly right clicking fails to close already opened context menus #1743: rapidly right clicking across ContextMenu triggers left earlier menus open.
  • A second outside pointerdown landing within the 10ms dismissal debounce replaced the pending one, so it was judged against the newly opened layer and the earlier layer never closed.
  • DismissibleLayerState now flushes the pending outside-interaction handler in the pointerdown capture phase, before the new event's state is marked, so each interaction is settled before the next begins.
  • debounce gains a flush() method that runs the pending call immediately (once), and destroy() now also clears the pending args.
  • Adds a patch changeset.

Testing

  • Added a debounce unit test: flush is a no-op with nothing pending, runs the latest pending call exactly once, and doesn't re-fire after the timer would have elapsed.
  • Added a ContextMenu browser test (context-menu-rapid-test.svelte): 20 rapid right clicks across 30 triggers leave only the last menu open.
  • Not run: tests were not run while writing this description.



- add `flush` to `debounce` to run the pending call immediately
- flush the pending outside-interaction before handling a new pointerdown
- add rapid right-click ContextMenu browser test and debounce unit test
- add changeset
@changeset-bot

changeset-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b4dd68f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
bits-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@huntabyte
huntabyte merged commit cf522ba into main Oct 20, 2026
7 checks passed
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
bits-ui ✅ Ready (View Log) Visit Preview b4dd68f

This branch was successfully deployed

1 active deployment
Preview — b4dd68f5 Deployed Oct 20, 2026 by github-actions[bot]
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.

Quickly right clicking fails to close already opened context menus

1 participant