Skip to content

Commit 60f287c

Browse files
fix: event order when switch anchors quickly
1 parent 8d20f32 commit 60f287c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/Tooltip/Tooltip.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,18 @@ const Tooltip = ({
7676

7777
useEffect(() => {
7878
if (!show) {
79-
setRendered(false)
79+
/**
80+
* this fixes weird behavior when switching between two anchor elements very quickly
81+
* remove the timeout and switch quickly between two adjancent anchor elements to see it
82+
*/
83+
const timeout = setTimeout(() => {
84+
setRendered(false)
85+
})
86+
return () => {
87+
clearTimeout(timeout)
88+
}
8089
}
90+
return () => null
8191
}, [show])
8292

8393
const handleShow = (value: boolean) => {

0 commit comments

Comments
 (0)