Skip to content

fix(Collapsible): announce trigger state and use its visible label as… - #1326

Open
Harika056 wants to merge 1 commit into
ClickHouse:mainfrom
Harika056:fix/collapsible-trigger-a11y
Open

Harika056 wants to merge 1 commit into
ClickHouse:mainfrom
Harika056:fix/collapsible-trigger-a11y

Conversation

@Harika056

@Harika056 Harika056 commented Nov 23, 2026 •

Copy link
Copy Markdown

Description

Collapsible.Trigger had two screen-reader problems:

  • No open/closed state. The button never set aria-expanded, so assistive technology could not tell whether the section was open.
  • A hard-coded, meaningless name. aria-label="trigger children" replaced the button's visible text, so a trigger showing "Advanced settings" was announced as "trigger children" (WCAG 2.5.3 Label in Name, 4.1.2 Name, Role, Value). SidebarCollapsibleTitle renders this trigger, so every collapsible sidebar section was announced that way. The decorative chevron (role="img", aria-label="chevron-right") was also part of the name.

Changes:

  • Set aria-expanded={open} on the trigger.
  • Drop the forced aria-label: a trigger with visible text is named by that text; an icon-only trigger gets "Toggle section". A consumer's aria-label still overrides it, because {...props} is spread after.
  • Hide the chevron from assistive technology with aria-hidden.
  • Tests: aria-expanded toggles; icon-only, visible-text and consumer aria-label names; SidebarCollapsibleTitle is named by its label.
  • Changeset (patch).

Good to know

  • aria-controls is not added: Collapsible.Content unmounts when closed, so there is nothing to point at while collapsed. Happy to follow up if you'd like it handled differently.
  • Consumers that queried the trigger by the old name "trigger children" would need to update that query. I found no such use in this repo.

Checklist

  • Breaking changes? (add migration notes in changesets)
  • Visual changes? (specify in changesets)
  • Design review needed?

Contribution

  • Sufficient research before PR
  • Self-reviewed the PR
  • Manually tested the changes (when applies - visual confirmation in Storybook)
  • build and build-storybook work locally
  • Tests and Stories are aligned with the changes

Accessibility

  • Keyboard - every action works with Tab / Enter / Space / Esc; focus is visible and returns to the trigger on close
  • Names — every control has a name that includes its visible label; icon-only controls take aria-label
  • Vision — colors come from tokens, focus ring shows, targets are at least 24×24 px (no visual change in this PR)

Tested: yarn vitest for Collapsible and SidebarCollapsibleTitle (8 passed), yarn lint:code (0 errors), Storybook Accessibility panel on Sidebar / CollapsibleTitle → Playground (0 violations), keyboard pass (Tab, Enter).
Not tested: yarn build / build-storybook; real screen readers (VoiceOver / NVDA).


Note

Low Risk
Accessibility-only patch on Collapsible trigger markup; no visual or behavioral UI change beyond correct ARIA. Tests may need updates only if they queried the old "trigger children" name.

Overview
Fixes Collapsible.Trigger screen-reader behavior without changing visuals.

The trigger now sets aria-expanded from the open state, removes the hard-coded aria-label="trigger children" so visible trigger text becomes the accessible name (icon-only triggers get "Toggle section"; consumer aria-label still wins via prop spread), and marks the chevron aria-hidden so it is not read as "chevron-right". SidebarCollapsibleTitle benefits because its label is passed as trigger children.

New unit tests cover aria-expanded toggling, naming for icon-only / text / override cases, and sidebar title accessibility. Patch changeset for @clickhouse/click-ui.

Reviewed by Cursor Bugbot for commit c45a0c9. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c45a0c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clickhouse/click-ui Patch

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit c45a0c9. Configure here.

aria-label="trigger children"
aria-expanded={open}
// With visible text, that text is the button's name. Icon-only: a generic name.
aria-label={children ? undefined : 'Toggle section'}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decorative icons leak into trigger name

Medium Severity

Removing the forced aria-label names the trigger from its contents, but Icon still sets aria-label to the icon identifier. SidebarCollapsibleTitle and IconWrapper render those icons inside the trigger without aria-hidden, so a titled section with an icon is announced as the icon name plus the label rather than the visible label alone.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c45a0c9. Configure here.

@XOP XOP added enhancement New feature or request a11y Accessibility improvements labels Nov 26, 2026
@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Chromatic Storybook

Check Status Link
Storybook ✅ 672 stories published Open Storybook
UI Tests ✅ 672 tests unchanged Open build

Built from commit: c45a0c99928597a3dd92eba253abad8e70276b7d · Chromatic run

Statuses as of the end of the run. The build link shows the live review state.

@XOP XOP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution! ✨
Please check and address small notes.

return (
<EmptyButton
onClick={onClick}
aria-label="trigger children"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the forced aria-label here lets decorative icons into the trigger's name:

  • <SidebarCollapsibleTitle label="Services" icon="code"> gives "code Services".
  • The Sidebar/CollapsibleTitle Playground story gives "code Queries".
  • <Collapsible.Trigger icon="settings">Advanced settings</Collapsible.Trigger> gives "settings Advanced settings".

It's worth checking further.

Suggested fix: add aria-hidden to the Icon elements that are affected, as this PR does for the chevron.
Please also add this check in SidebarCollapsibleTitle.test.tsxand keep toHaveAccessibleName('Services').

name="chevron-right"
data-open={open.toString()}
size="sm"
aria-hidden

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no test reaches this end chevron. When I removed this aria-hidden, all 8 tests still passed. A test like the one at Collapsible.test.tsx:52, using <Collapsible.Trigger indicatorDir="end">Advanced settings</Collapsible.Trigger> and expecting the name "Advanced settings", would catch it.

This branch has not been deployed

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

Labels

a11y Accessibility improvements enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants