Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,10 @@ const Tooltip = ({

const enabledEvents: { event: string; listener: (event?: Event) => void }[] = []

const activeAnchorContainsTarget = (event?: Event): boolean =>
Boolean(event?.target && activeAnchor?.contains(event.target as HTMLElement))
const handleClickOpenTooltipAnchor = (event?: Event) => {
if (show && event?.target === activeAnchor) {
if (show && activeAnchorContainsTarget(event)) {
/**
* ignore clicking the anchor that was used to open the tooltip.
* this avoids conflict with the click close event.
Expand All @@ -526,7 +528,7 @@ const Tooltip = ({
handleShowTooltip(event)
}
const handleClickCloseTooltipAnchor = (event?: Event) => {
if (!show || event?.target !== activeAnchor) {
if (!show || !activeAnchorContainsTarget(event)) {
/**
* ignore clicking the anchor that was NOT used to open the tooltip.
* this avoids closing the tooltip when clicking on a
Expand Down