Skip to content

fix(sidebar): render SidebarItem parts inside the asChild element - #87

Merged
TheGreatAxios merged 1 commit into
mainfrom
fix/sidebar-item-aschild
Oct 8, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
fix/sidebar-item-aschild

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

What changed

SidebarItem passed an icon span, the label span and a count span as children of Comp, and with asChild that Comp is a Radix Slot, which accepts exactly one child. Wrapping a router link therefore threw React.Children.only. The parts are now injected into the consumer's element, so the rendered markup is the same as the anchor case and Slot merges the item's class, aria-current and data-slot onto the link.

Verification

  • New src/ui/sidebar.test.tsx renders asChild with an icon and count and checks the link carries the href, aria-current, data-slot, the icon and the label and count text.
  • bun run check (typecheck, lint, format, 240 tests).

Closes CL-10221

Slot accepts one child, so asChild threw React.Children.only whenever an
icon or count was set. The icon, label and count now go inside the
consumer's element, which keeps the markup identical to the anchor case.
@TheGreatAxios
TheGreatAxios merged commit 7a8fcc1 into main Oct 8, 2026
2 checks passed
@TheGreatAxios
TheGreatAxios deleted the fix/sidebar-item-aschild branch October 8, 2026 21:04
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.

1 participant