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

Commit 89d7760

Browse files
authored
Don't leave button tooltips open when closing modals (#8546)
1 parent 617c0e3 commit 89d7760

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/views/elements/AccessibleTooltipButton.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import React, { SyntheticEvent } from 'react';
18+
import React, { SyntheticEvent, FocusEvent } from 'react';
1919

2020
import AccessibleButton from "./AccessibleButton";
2121
import Tooltip, { Alignment } from './Tooltip';
@@ -68,6 +68,12 @@ export default class AccessibleTooltipButton extends React.PureComponent<IProps,
6868
this.props.onHideTooltip?.(ev);
6969
};
7070

71+
private onFocus = (ev: FocusEvent) => {
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)