Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit be066af

Browse files
committed
Don't leave tooltips on buttons open when closing modals
1 parent 617c0e3 commit be066af

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/views/elements/AccessibleTooltipButton.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ export default class AccessibleTooltipButton extends React.PureComponent<IProps,
6868
this.props.onHideTooltip?.(ev);
6969
};
7070

71+
private onFocus = (ev: SyntheticEvent) => {
72+
// We only show the tooltip if focus arrived here from some other
73+
// element, to avoid leaving tooltips hanging around when a modal closes
74+
if (ev.relatedTarget) this.showTooltip();
75+
};
76+
7177
render() {
7278
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7379
const { title, tooltip, children, tooltipClassName, forceHide, yOffset, alignment, onHideTooltip,
@@ -84,7 +90,7 @@ export default class AccessibleTooltipButton extends React.PureComponent<IProps,
8490
{...props}
8591
onMouseOver={this.showTooltip}
8692
onMouseLeave={this.hideTooltip}
87-
onFocus={this.showTooltip}
93+
onFocus={this.onFocus}
8894
onBlur={this.hideTooltip}
8995
aria-label={title}
9096
>

0 commit comments

Comments
 (0)