Skip to content

fix(NavigationMenu): only register layers for open force-mounted content - #2218

Merged
huntabyte merged 1 commit into
mainfrom
fix/2034-navigation-menu-force-mount
Oct 20, 2026
Merged

huntabyte merged 1 commit into
mainfrom
fix/2034-navigation-menu-force-mount

Conversation

@huntabyte

Copy link
Copy Markdown
Owner

Summary

  • NavigationMenu.Content now enables its DismissibleLayer and EscapeLayer only while its item is open, instead of always (enabled={true}).
  • Previously, with forceMount, closed contents kept their layers registered. Clicking inside the open item's content counted as an outside interaction for the other contents, which closed the open item (with openOnHover={false}). Closed contents could also take over escape handling, so focus didn't return to the trigger.
  • Added an open derived value to NavigationMenuContentImplState. The layer enabled props and data-state both use it.
  • Added a patch changeset.
  • Fixes NavigationMenu inconsistent behavior with openOnHover and forceMount props #2034.

Testing

  • Added browser tests in navigation-menu.browser.test.ts, using a new navigation-menu-force-mount-test.svelte fixture:
    • Clicking inside a force-mounted item's content keeps it open with openOnHover={false}.
    • Clicking outside closes a non-last force-mounted item.
    • Escape closes the open item and returns focus to its trigger when contents are force-mounted.
  • Not run: tests were not run as part of writing this description.

- Enable DismissibleLayer and EscapeLayer only while the content's item is open
- Stop closed force-mounted content from closing the open item on inside clicks or stealing escape focus
- Expose `open` on NavigationMenuContentImplState and reuse it for `data-state`
- Add browser tests and a changeset
@changeset-bot

changeset-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 886e0be

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

@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 886e0be

@huntabyte
huntabyte merged commit 872ec79 into main Oct 20, 2026
8 of 9 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 20, 2026

This branch was successfully deployed

1 active deployment
Preview — 886e0bea 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.

NavigationMenu inconsistent behavior with openOnHover and forceMount props

1 participant