Skip to content

Commit

Permalink
feat(collapsible): omit aria-controls when closed
Browse files Browse the repository at this point in the history
The `aria-controls` attribute should be set only when an element with the
specified id is available in the DOM.
  • Loading branch information
dodomorandi committed Jan 13, 2025
1 parent 2b206a8 commit 6bb71d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react/collapsible/src/Collapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const CollapsibleTrigger = React.forwardRef<CollapsibleTriggerElement, Collapsib
return (
<Primitive.button
type="button"
aria-controls={context.contentId}
aria-controls={context.open ? context.contentId : undefined}
aria-expanded={context.open || false}
data-state={getState(context.open)}
data-disabled={context.disabled ? '' : undefined}
Expand Down

0 comments on commit 6bb71d0

Please sign in to comment.