Skip to content

Commit 985e1d4

Browse files
fix: click events behavior
1 parent 9738899 commit 985e1d4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/components/Tooltip/Tooltip.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,20 @@ const Tooltip = ({
477477
const enabledEvents: { event: string; listener: (event?: Event) => void }[] = []
478478

479479
const handleClickOpenTooltipAnchor = (event?: Event) => {
480-
if (show) {
480+
if (show && event?.target === activeAnchor) {
481+
/**
482+
* ignore clicking the anchor that was used to open the tooltip.
483+
* this avoids conflict with the click close event.
484+
*/
481485
return
482486
}
483487
handleShowTooltip(event)
484488
}
485-
const handleClickCloseTooltipAnchor = () => {
486-
if (!show) {
489+
const handleClickCloseTooltipAnchor = (event?: Event) => {
490+
if (!show || event?.target !== activeAnchor) {
491+
/**
492+
* same reasoning as above, opposite logic.
493+
*/
487494
return
488495
}
489496
handleHideTooltip()

0 commit comments

Comments
 (0)