fix(a11y): a tooltip no longer stays open when focus returns to its button after a mouse click (#33170)

This commit is contained in:
G30 2026-10-25 03:55:43 -04:00 • committed by GitHub
parent 0286709f9c
commit af6c382d3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -59,6 +59,16 @@
allowHTML,
touch,
trigger: 'mouseenter focusin',
onShow: () => {
const focused = document.activeElement;
if (
!tooltipElement?.matches(':hover') &&
tooltipElement?.contains(focused) &&
!focused?.matches(':focus-visible')
) {
return false;
}
},
...(theme !== '' ? { theme } : { theme: 'dark' }),
arrow: false,
offset,
@ -74,7 +84,7 @@
};
return {
onShow: () => document.addEventListener('keydown', onKeyDown),
onMount: () => document.addEventListener('keydown', onKeyDown),
onHide: () => document.removeEventListener('keydown', onKeyDown),
onDestroy: () => document.removeEventListener('keydown', onKeyDown)
};