Skip to content

Commit ca4afa1

Browse files
authored
Set aria-label to title if no label for (#16262)
Co-authored-by: Frédéric Collonval <[email protected]>
1 parent 9ac9069 commit ca4afa1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/ui-components/src/components/toolbar.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ export function ToolbarButtonComponent(
843843
}
844844
};
845845

846+
const title = getTooltip();
847+
const disabled = props.enabled === false;
848+
846849
return (
847850
<Button
848851
appearance="stealth"
@@ -851,14 +854,15 @@ export function ToolbarButtonComponent(
851854
? props.className + ' jp-ToolbarButtonComponent'
852855
: 'jp-ToolbarButtonComponent'
853856
}
857+
aria-disabled={disabled}
858+
aria-label={props.label || title}
854859
aria-pressed={props.pressed}
855-
aria-disabled={props.enabled === false}
856860
{...props.dataset}
857-
disabled={props.enabled === false}
861+
disabled={disabled}
858862
onClick={handleClick}
859863
onMouseDown={handleMouseDown}
860864
onKeyDown={handleKeyDown}
861-
title={getTooltip()}
865+
title={title}
862866
minimal
863867
>
864868
{(props.icon || props.iconClass) && (

0 commit comments

Comments
 (0)