Repository navigation
fix(sidebar): render SidebarItem parts inside the asChild element - #87
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
SidebarItempassed an icon span, the label span and a count span as children ofComp, and withasChildthatCompis a RadixSlot, which accepts exactly one child. Wrapping a router link therefore threwReact.Children.only. The parts are now injected into the consumer's element, so the rendered markup is the same as the anchor case andSlotmerges the item's class,aria-currentanddata-slotonto the link.Verification
src/ui/sidebar.test.tsxrendersasChildwith 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