Repository navigation
Conversation
…ch the link The link now gets aria-current="page" when selected, and aria-disabled, tabIndex -1 and a click guard when disabled. Without asChild nothing changes. Closes ClickHouse#1304
🦋 Changeset detectedLatest commit: 0bb6575 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
1 of 4 tasks
emunhoz
marked this pull request as ready for review
November 18, 2026 09:29
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit d7284e9. Configure here.
This branch has not been deployed
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.

Description
SidebarNavigationItemputsdata-selectedandaria-disabledon its wrapperdiv, so the consumer's link (passed throughlabel) never gets either state. This adds an opt-inasChildprop, the direction suggested in the issue, so the item renders the consumer's link itself:aria-current="page". A consumer-providedaria-currentwins (RadixSlotlets child props take precedence).aria-disabled="true"andtabIndex={-1}, and click (which Enter fires on a link) is prevented. This follows the existingCardHorizontalpattern (fix(a11y): add keyboard activation and button role to CardHorizontal #1269).aria-hiddeninside the link so the accessible name is "Tables", not "table Tables" (new optionaliconHiddenon the internalCollapsible/IconWrapper; other users of it are unchanged)..wrapper:focus-visibleuses the global outline token with a-2pxoffset because.wrapperhasoverflow: hidden. Same values as fix(Collapsible): show focus ring on keyboard focus of the trigger #1312.asChildthe output is unchanged. The existinglabel={<a/>}usage keeps working.asChilduses@radix-ui/react-slot, which is already a dependency. No new dependency.Links and tickets
Closes #1304
Good to know
href: the ideal markup for a disabled link is to drophrefand userole="link"+aria-disabled(Scott O'Hara, "Disabling a link"). WithasChildthe child's props win, so the component can't remove the consumer'shref/to. That's why it keeps the link out of the Tab order and prevents activation instead. Happy to change direction if you prefer anhrefprop that the component owns.labelis now optional in the type, since withasChildthe link's own content is the label (JSDoc says so). I keptinterfacerather than a discriminated union so consumers extendingSidebarNavigationItemPropsdon't break.reftype staysHTMLDivElementeven though inasChildmode the element is an<a>. Widening it toHTMLElementcould break typed callback refs, so I left it as is.onClickplaced directly on the child<a>still runs when disabled; navigation is still blocked.pointer-events: noneon disabled items also hides thecursor: not-allowed. I didn't change it here.Checklist
asChildlinks. Existing stories are unchanged.Contribution
buildandbuild-storybookwork locallyAccessibility
aria-hidden.Checked: 4.1.2 Name, Role, Value; 1.3.1 Info and Relationships; 2.1.1 Keyboard; 2.4.7 Focus Visible; 1.4.11 Non-text Contrast (light ring on the selected background ≈ 3.07:1, global token).
How:
aria-current, a consumeraria-current, Tab moving focus to the link, the ref reaching the<a>, and disabled (aria-disabled, skipped by Tab, click prevented,onClicknot called).as-child-selectedandas-child-disabledsnapshots, anas-childfocus case (body click, Tab,toBeFocused, screenshot) in light and dark likecheckbox.spec.ts, and a check that a disabled link is skipped by Tab. Six new snapshots; the existing 12 are untouched.AsChild,AsChildSelectedandAsChildDisabled. I left out pseudo-state andplaystories, following the review on fix(SplitButton): make the menu half a keyboard-accessible menu button #1278.yarn test:visualfor Collapsible, SidebarNavigationTitle and SidebarCollapsibleItem (they shareIconWrapper): passing, no snapshot updates.Not tested: a real screen reader (VoiceOver/NVDA) and a real router
Link(no router in the repo).Screenshots
From the visual regression snapshots. Existing
label={<a/>}usage (unchanged) next toasChild:label)asChildNote
Low Risk
Opt-in API with unchanged default rendering; changes are localized to sidebar navigation and shared icon accessibility, with broad test coverage.
Overview
Adds an opt-in
asChildprop so consumers can pass a routerLinkor<a>as the item root (via RadixSlot).selectedanddisabledthen land on the link:aria-current="page"(unless the child already setsaria-current),aria-disabled,tabIndex={-1}when disabled, and click prevention that also blocks Enter activation.IconWrappergains optionaliconHiddenso sidebar icons are decorative inside link items. Styles addtext-decoration: noneon the wrapper and a:focus-visiblering for keyboard focus on link-as-item markup.labelbecomes optional whenasChildis used; defaultlabel={…}behavior is unchanged.Stories, unit tests, and Playwright snapshots cover
asChildselected, disabled, and focus states. Changeset marks a minor@clickhouse/click-uirelease.Reviewed by Cursor Bugbot for commit 0bb6575. Bugbot is set up for automated code reviews on this repo. Configure here.