Skip to content

[Toolkit][Shadcn] Add menubar recipe#3486

Open
Amoifr wants to merge 5 commits intosymfony:3.xfrom
Amoifr:feat/toolkit-shadcn-menubar
Open

[Toolkit][Shadcn] Add menubar recipe#3486
Amoifr wants to merge 5 commits intosymfony:3.xfrom
Amoifr:feat/toolkit-shadcn-menubar

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 menubar recipe to the Shadcn kit.

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

Snapshots will be regenerated after rework.

@Amoifr
Copy link
Copy Markdown
Contributor Author

Amoifr commented Apr 19, 2026

Main example

Capture.video.du.2026-04-19.19-20-55.mp4

@Amoifr
Copy link
Copy Markdown
Contributor Author

Amoifr commented Apr 19, 2026

Checkbox example (better than original)

Capture.video.du.2026-04-19.19-24-46.mp4

@Amoifr
Copy link
Copy Markdown
Contributor Author

Amoifr commented Apr 19, 2026

Radio example (better than original)

Capture.video.du.2026-04-19.19-39-30.mp4

@Amoifr
Copy link
Copy Markdown
Contributor Author

Amoifr commented Apr 19, 2026

Submenu example :

Capture.video.du.2026-04-19.19-41-19.mp4

@Amoifr
Copy link
Copy Markdown
Contributor Author

Amoifr commented Apr 19, 2026

With icons :

Capture.video.du.2026-04-19.19-43-56.mp4

@Amoifr
Copy link
Copy Markdown
Contributor Author

Amoifr commented Apr 19, 2026

RTL example

Capture.video.du.2026-04-19.19-49-43.mp4

@Amoifr Amoifr force-pushed the feat/toolkit-shadcn-menubar branch from d89e1c0 to 4185895 Compare April 19, 2026 17:53
@Amoifr Amoifr marked this pull request as ready for review April 19, 2026 17:54
@Amoifr Amoifr requested a review from Kocal as a code owner April 19, 2026 17:54
@carsonbot carsonbot added Feature New Feature Toolkit Status: Needs Review Needs to be reviewed labels Apr 19, 2026
Amoifr added 3 commits April 27, 2026 09:45
Follow up on the review feedback on symfony#3487: the Trigger and SubTrigger
templates should not enforce a specific HTML element but expose a Twig
variable with the needed attributes so the consumer can pick their own
element.
@Amoifr Amoifr force-pushed the feat/toolkit-shadcn-menubar branch from 1ebf71c to 76bcd84 Compare April 27, 2026 07:53
Apply the same hover/focus pattern as hover-card and navigation-menu.
The previous CSS-only approach (group-hover + group-focus-within +
tabindex=0 on submenu) left submenus stuck open after a click. Add a
shared menubar_controller.js toggling data-state, wire mouseenter/
mouseleave on Menu and Sub, focus/blur on Trigger and SubTrigger, and
switch Content + SubContent to in-data-[state=open] selectors.
@Amoifr Amoifr force-pushed the feat/toolkit-shadcn-menubar branch from 76bcd84 to ff6220a Compare April 27, 2026 08:07
@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/menubar-menu + group-focus-within/menubar-sub + tabindex="0" trio, which has the now-familiar UX issue: clicking a trigger gives it focus, so the menu stays stuck open even after the mouse leaves.

The fix follows the same approach as hover-card and navigation-menu, with one menubar-specific twist:

  • New shared menubar_controller.js toggling data-state, attached to both Menu and Sub
  • mouseenter/mouseleave on Menu and Sub, focus/blur on Trigger and SubTrigger
  • Because Sub is nested inside Menu's Content, the naive in-data-[state=open]:visible selector matches any ancestor with data-state=open — opening Edit was also opening the Find sub-menu. Switched to named groups (group/menubar-menu + group-data-[state=open]/menubar-menu:visible and the same for menubar-sub) so each Content is scoped to its own wrapper.
  • Optional openDelay / closeDelay props on Menu and Sub, default 0

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

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

Avoid duplicating the radio group `name` on each `Menubar:RadioItem`. The
parent `Menubar:RadioGroup` now exposes its `name` to its direct children
through a Twig variable; `RadioItem` falls back to it when its own `name`
is omitted.
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