Skip to content

Commit

Permalink
fix: race condition in DefinitionTooltip
Browse files Browse the repository at this point in the history
`onClick` -> `onMouseDown` so the action happens before `onFocus`.
  • Loading branch information
frankharkins committed Oct 1, 2024
1 parent 6bd017d commit f99ebb6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/react/src/components/Tooltip/DefinitionTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ const DefinitionTooltip: React.FC<DefinitionTooltipProps> = ({
onBlur={() => {
setOpen(false);
}}
onClick={() => {
setOpen(!isOpen);
onMouseDown={(event) => {
// We use onMouseDown rather than onClick to make sure this triggers
// before onFocus.
if (event.button === 0) setOpen(!isOpen);
}}
onKeyDown={onKeyDown}
type="button">
Expand Down

0 comments on commit f99ebb6

Please sign in to comment.