Skip to content

Conversation

@huntabyte
Copy link
Owner

@huntabyte huntabyte commented May 23, 2025

This pull request introduces bug fixes and enhancements to the NavigationMenu component in the bits-ui library, along with updates to the documentation and demos. The changes address issues with transitions, improve submenu behavior, and add new demo components for better visualization.

Bug Fixes:

  • Fixed an issue where moving from a submenu trigger to a menu item in the same menu did not close the submenu (NavigationMenu).
  • Resolved problems with non-viewport transitions in the NavigationMenu component.

Documentation Updates:

  • Updated navigation-menu.md to include new demos for submenus and non-viewport transitions, replacing code snippets with interactive previews.

New Demo Components:

  • Added navigation-menu-no-viewport-demo.svelte to demonstrate NavigationMenu transitions without a viewport.
  • Added navigation-menu-submenu-demo.svelte to showcase nested submenus with improved interaction.

Enhancements to NavigationMenu:

  • Introduced Mounted utility in navigation-menu-viewport.svelte to track mounted state for viewport transitions.
  • Enhanced NavigationMenuRootState to reset previousValue when all menus are closed, preventing unwanted transitions.

@changeset-bot
Copy link

changeset-bot bot commented May 23, 2025

🦋 Changeset detected

Latest commit: da1cb4c

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
Copy link
Contributor

github-actions bot commented May 23, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

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

@huntabyte huntabyte requested a review from Copilot May 23, 2025 19:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses residual transition issues in the navigation menu’s submenus and viewport, adds pointer‐hover logic to close and switch submenu content, and introduces demos and tests for these behaviors.

  • Reset previousValue and viewport size/motion state when menus close to prevent stale animations
  • Add pointer event handlers (onpointerenter/onpointermove) to auto‐dismiss submenus when hovering between items
  • Introduce mounted state and <Mounted> binding for the viewport, plus new tests and documentation demos

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/src/tests/navigation-menu/navigation-menu.test.ts New test verifying submenu item switching on pointer hover
packages/bits-ui/src/lib/bits/navigation-menu/navigation-menu.svelte.ts State resets, pointer event handlers, mounted flag, context updates
packages/bits-ui/src/lib/bits/navigation-menu/components/navigation-menu-viewport.svelte Bind <Mounted> to reset viewport size after unmount
docs/src/lib/components/demos/navigation-menu-submenu-demo.svelte New submenu demo
docs/src/lib/components/demos/navigation-menu-no-viewport-demo.svelte New no-viewport demo
docs/src/lib/components/demos/index.ts Export new demo components
docs/content/components/navigation-menu.md Add submenu and no-viewport examples to docs
.changeset/moody-carrots-ring.md Patch noting non-viewport transition fixes
.changeset/dry-bees-yawn.md Patch noting submenu trigger dismissal fix
Comments suppressed due to low confidence (3)

packages/bits-ui/src/lib/bits/navigation-menu/navigation-menu.svelte.ts:582

  • The new onpointerenter and corresponding onpointermove logic in NavigationMenuLinkState should be covered by unit or integration tests to verify that submenus close as expected when hovering between items.
onpointerenter: PointerEventHandler<HTMLAnchorElement> = () => {

packages/bits-ui/src/lib/bits/navigation-menu/navigation-menu.svelte.ts:48

  • The import useGraceArea is not used in this file and can be removed to reduce dead code and simplify maintenance.
import { useGraceArea } from "$lib/internal/use-grace-area.svelte.js";

packages/bits-ui/src/lib/bits/navigation-menu/navigation-menu.svelte.ts:592

  • [nitpick] For consistency with other event handlers (onpointerenter, onclick, etc.), annotate onpointermove with PointerEventHandler<HTMLAnchorElement>.
onpointermove = whenMouse(() => {

@huntabyte huntabyte merged commit 66acab5 into main May 23, 2025
5 checks passed
@github-actions github-actions bot mentioned this pull request May 23, 2025
@huntabyte huntabyte deleted the fix/nav-menu-submenus branch May 27, 2025 00:36
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.

2 participants