Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion v3/src/components/inspector-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import { isWithinBounds, getPaletteTopPosition } from "../utilities/view-utils"

import "./inspector-panel.scss"

// Returns an aria-label for icon-only inspector buttons/menus.
// When a visible text label exists, returns undefined (the label provides the accessible name).
// When no label exists, returns the tooltip with parenthetical keyboard shortcuts stripped
// (e.g. "bold (⌘-b)" → "bold") so screen readers announce a clean name.
function ariaLabel(label?: string, tooltip?: string) {
if (label) return undefined
return tooltip?.replace(/\s*\(.*\)$/, "")
}

interface IProps {
component?: string
show?: boolean
Expand Down Expand Up @@ -49,6 +58,7 @@ export const InspectorButton = forwardRef(function InspectorButton({
const className = clsx("inspector-tool-button", { active: isActive, bottom, top })
return (
<Button
aria-label={ariaLabel(label, tooltip)}
className={className}
isDisabled={isDisabled}
data-testid={testId}
Expand Down Expand Up @@ -81,7 +91,8 @@ export const InspectorMenu = ({
const classes = clsx("inspector-tool-button", "inspector-tool-menu", { bottom, top })
return (
<Menu isLazy onOpen={onOpen}>
<MenuButton className={classes} title={tooltip} data-testid={testId} onClick={onButtonClick}>
<MenuButton aria-label={ariaLabel(label, tooltip)} className={classes} title={tooltip} data-testid={testId}
onClick={onButtonClick}>
{icon}
{label && <span className="inspector-button-label">{label}</span>}
</MenuButton>
Expand Down
2 changes: 1 addition & 1 deletion v3/src/components/tool-shelf/plugins-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const PluginsButton = observer(function PluginsButton() {
<>
<MenuButton
className={className}
title={t("DG.ToolButtonData.optionMenu.toolTip")}
title={t("DG.ToolButtonData.pluginMenu.toolTip")}
data-testid="tool-shelf-button-plugins"
>
<PluginsIcon />
Expand Down