Skip to content

[Toolkit][Shadcn] Add navigation-menu recipe#3484

Open
Amoifr wants to merge 4 commits intosymfony:3.xfrom
Amoifr:feat/toolkit-shadcn-navigation-menu
Open

[Toolkit][Shadcn] Add navigation-menu recipe#3484
Amoifr wants to merge 4 commits intosymfony:3.xfrom
Amoifr:feat/toolkit-shadcn-navigation-menu

Conversation

@Amoifr
Copy link
Copy Markdown
Contributor

@Amoifr Amoifr commented Apr 18, 2026

Q A
Bug fix? no
New feature? yes
Deprecations? no
Documentation? no
Issues Part of #3233
License MIT

Adds the navigation-menu recipe to the Shadcn kit.

Part of the split of #3467 into one PR per component, tracking #3233.

Snapshots will be regenerated after rework.

Amoifr added 4 commits April 27, 2026 08:28
Follow up on the review feedback on symfony#3487: the Trigger template
should not enforce a specific HTML element but expose a Twig variable
with the needed attributes so the consumer can pick their own element.
…controller

Apply the same hover/focus pattern as hover-card. The previous CSS-only
approach (group-hover + group-focus-within + tabindex=0) left submenus
stuck open after a click. Add a navigation_menu_controller.js toggling
data-state on the Item, wire mouseenter/mouseleave on the Item and
focus/blur on the Trigger, and switch Content + chevron rotation from
group-hover/nav-item to in-data-[state=open] selectors.
@Amoifr Amoifr force-pushed the feat/toolkit-shadcn-navigation-menu branch from 89226bd to 21166a7 Compare April 27, 2026 07:31
@Amoifr
Copy link
Copy Markdown
Contributor Author

Amoifr commented Apr 27, 2026

Hi @Kocal! Just pushed an update aligning this recipe with the patterns we've validated on the other Shadcn components shipped recently (notably hover-card #3478 merged earlier today).

The original implementation relied on the pure-CSS group-hover/nav-item + group-focus-within/nav-item + tabindex="0" trio, which we found out has a real UX issue: clicking a trigger gives it focus, so the submenu stays stuck open even after the mouse leaves. Removing group-focus-within fixes the click case but breaks keyboard accessibility.

The fix follows the same approach you confirmed for hover-card:

  • New navigation_menu_controller.js toggling data-state on the Item (one controller per item)
  • mouseenter/mouseleave on the Item, focus/blur on the Trigger
  • Content and chevron rotation use in-data-[state=open]:… instead of group-hover/nav-item
  • Optional openDelay / closeDelay props on Item, default 0

Companion PR for ux.symfony.com is updated too: symfony/ux.symfony.com#68.

No rush at all, just letting you know it's ready for another look! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New Feature Status: Needs Review Needs to be reviewed Toolkit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants