Skip to content

NavigationMenu inconsistent behavior with openOnHover and forceMount props #2034

@heyharvest

Description

@heyharvest

Describe the bug

Running into strange/unexpected behavior with NavigationMenu.

Given the following:

  • There are two or more <NavigationMenu.Item> / <NavigationMenu.Content> components in a <NavigationMenu>
  • One or more instances have set the forceMount prop
  • One or more instances set openOnHover to false

An item that has forceMount set can be "closed" by an inside click/pointer/mousedown event. This prevents interaction/event handling with any links or other child elements if managing visibility with CSS i.e. display: none.

This behavior does not seem consistent either. Included an example in the reproduction that is the same as the main example, just with a couple elements swapped, and the issue goes away.

The structure I am trying to achieve uses forceMount and openOnHover={false} on all elements but this seems to consistently fail for me. It does work if openOnHover is not set.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-xlyx311c?file=src%2Froutes%2Fforce-mount-only%2F%2Bpage.svelte

Logs

System Info

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 91.94 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - /Users/acmebkmpbharvest/.volta/tools/image/node/22.14.0/bin/node
    Yarn: 3.4.1 - /Users/acmebkmpbharvest/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 11.1.0 - /Users/acmebkmpbharvest/.volta/tools/image/npm/11.1.0/bin/npm
  Browsers:
    Chrome: 147.0.7727.56
    Firefox: 147.0.3
    Safari: 26.2
  npmPackages:
    @sveltejs/kit: ^2.57.1 => 2.57.1 
    bits-ui: ^2.18.0 => 2.18.0 
    svelte: ^5.55.4 => 5.55.4

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageA maintainer needs to review this issue and label it appropriately

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions