Skip to content

Commit

Permalink
fix: race condition in DefinitionTooltip (#17622)
Browse files Browse the repository at this point in the history
`onClick` -> `onMouseDown` so the action happens before `onFocus`.
  • Loading branch information
frankharkins authored Oct 2, 2024
1 parent c0d2b32 commit 204508f
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 204508f

Please sign in to comment.