diff --git a/packages/react/src/TooltipV2/Tooltip.tsx b/packages/react/src/TooltipV2/Tooltip.tsx index 92f0599da98..0b0315065e0 100644 --- a/packages/react/src/TooltipV2/Tooltip.tsx +++ b/packages/react/src/TooltipV2/Tooltip.tsx @@ -276,6 +276,40 @@ export const Tooltip: ForwardRefExoticComponent< return ( <> + + {keybindingHint ? ( + <> + + {text} + {/* There is a bug in Chrome browsers where `aria-hidden` text inside the target of an `aria-labelledby` + still gets included in the accessible label. `KeybindingHint` renders the symbols as `aria-hidden` text + and renders full key names as `VisuallyHidden` text. Due to the browser bug this causes the label text + to duplicate the symbols and key names. To work around this, we exclude the hint from being part of the + label and instead render the plain keybinding description string. */} + ({getAccessibleKeybindingHintString(keybindingHint, isMacOS)}) + + + + + + ) : ( + text + )} + {React.isValidElement(child) && // eslint-disable-next-line react-hooks/refs React.cloneElement(child as React.ReactElement, { @@ -340,40 +374,6 @@ export const Tooltip: ForwardRefExoticComponent< child.props.onMouseLeave?.(event) }, })} - - {keybindingHint ? ( - <> - - {text} - {/* There is a bug in Chrome browsers where `aria-hidden` text inside the target of an `aria-labelledby` - still gets included in the accessible label. `KeybindingHint` renders the symbols as `aria-hidden` text - and renders full key names as `VisuallyHidden` text. Due to the browser bug this causes the label text - to duplicate the symbols and key names. To work around this, we exclude the hint from being part of the - label and instead render the plain keybinding description string. */} - ({getAccessibleKeybindingHintString(keybindingHint, isMacOS)}) - - - - - - ) : ( - text - )} - )