Skip to content

Commit

Permalink
Fixed Toggle aria-labelledby (#16151)
Browse files Browse the repository at this point in the history
* fix: added logic to set the value to empty

* fix: fixed stories without a label

* docs: changed label name

* fix: removed commnets

* fix: replace empty string with undefined

---------

Co-authored-by: Andrea N. Cardona <[email protected]>
  • Loading branch information
guidari and andreancardona authored May 14, 2024
1 parent f0d89db commit fd0f464
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/react/src/components/Toggle/Toggle.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export const WithAccessibleLabels = () => (

<div>
<div id="toggle-6-label" style={{ marginBlockEnd: '0.5rem' }}>
External toggle label
Internal aria-label toggle
</div>
<Toggle id="toggle-6" hideLabel />
<Toggle aria-label="Internal aria-label toggle" id="toggle-6" hideLabel />
</div>

<div>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export function Toggle({
role="switch"
type="button"
aria-checked={checked}
aria-labelledby={ariaLabelledby ?? labelId}
aria-labelledby={ariaLabelledby ?? (labelText ? labelId : undefined)}
disabled={disabled}
onClick={handleClick}
/>
Expand Down

0 comments on commit fd0f464

Please sign in to comment.