Skip to content

Commit

Permalink
fix(react): use capture phase instead of bubble phase for esc keypres…
Browse files Browse the repository at this point in the history
…s on Tooltip (#1569)
  • Loading branch information
scurker authored Jul 10, 2024
1 parent 66bea50 commit 1bc0e02
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/react/src/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,17 @@ export default function Tooltip({

const targetElement = document.body;
if (showTooltip) {
targetElement.addEventListener('keyup', handleEscape);
targetElement.addEventListener('keyup', handleEscape, { capture: true });
} else {
targetElement.removeEventListener('keyup', handleEscape);
targetElement.removeEventListener('keyup', handleEscape, {
capture: true
});
}

return () => {
targetElement.removeEventListener('keyup', handleEscape);
targetElement.removeEventListener('keyup', handleEscape, {
capture: true
});
};
}, [showTooltip]);

Expand Down

0 comments on commit 1bc0e02

Please sign in to comment.