Skip to content

Commit e2f7b15

Browse files
refactor: declaration position
1 parent a41ec13 commit e2f7b15

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/Tooltip/Tooltip.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const Tooltip = ({
5656
const { anchorRefs, setActiveAnchor: setProviderActiveAnchor } = useTooltip(id)
5757
const hoveringTooltip = useRef(false)
5858
const [anchorsBySelect, setAnchorsBySelect] = useState<HTMLElement[]>([])
59+
const mounted = useRef(false)
5960

6061
useEffect(() => {
6162
let selector = anchorSelect
@@ -73,7 +74,6 @@ const Tooltip = ({
7374
setAnchorsBySelect([])
7475
}
7576
}, [anchorSelect])
76-
const mounted = useRef(false)
7777

7878
/**
7979
* useLayoutEffect runs before useEffect,
@@ -92,6 +92,8 @@ const Tooltip = ({
9292
/**
9393
* this fixes weird behavior when switching between two anchor elements very quickly
9494
* remove the timeout and switch quickly between two adjancent anchor elements to see it
95+
*
96+
* in practice, this means the tooltip is not immediately removed from the DOM on hide
9597
*/
9698
const timeout = setTimeout(() => {
9799
setRendered(false)
@@ -268,11 +270,9 @@ const Tooltip = ({
268270
if (anchorById?.contains(event.target as HTMLElement)) {
269271
return
270272
}
271-
272273
if (anchorsBySelect.some((anchor) => anchor.contains(event.target as HTMLElement))) {
273274
return
274275
}
275-
276276
handleShow(false)
277277
}
278278

0 commit comments

Comments
 (0)