Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ const Tooltip = ({
lastFloatPosition,
openEvents,
openOnClick,
rendered,
setActiveAnchor,
show,
tooltipHideDelayTimerRef,
Expand Down
6 changes: 5 additions & 1 deletion src/components/Tooltip/use-tooltip-events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const useTooltipEvents = ({
lastFloatPosition,
openEvents,
openOnClick,
rendered,
setActiveAnchor,
show,
tooltipHideDelayTimerRef,
Expand All @@ -62,6 +63,7 @@ const useTooltipEvents = ({
lastFloatPosition: RefObject<IPosition | null>
openEvents?: AnchorOpenEvents
openOnClick: boolean
rendered: boolean
setActiveAnchor: (anchor: HTMLElement | null) => void
show: boolean
tooltipHideDelayTimerRef: RefObject<NodeJS.Timeout | null>
Expand Down Expand Up @@ -447,8 +449,10 @@ const useTooltipEvents = ({
debouncedShow.cancel()
debouncedHide.cancel()
}
// `rendered` needs to be a dependency because `tooltipRef` becomes stale when the
// tooltip is removed from / added to the DOM.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [actualOpenEvents, actualCloseEvents, float, clickable])
}, [actualOpenEvents, actualCloseEvents, float, clickable, rendered])

// --- Effect 2: Global close events + auto-update ---
// Re-runs when the global close config changes, or when the active anchor changes
Expand Down
6 changes: 5 additions & 1 deletion src/test/tooltip-interaction-behavior.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ describe('tooltip interaction behavior', () => {

unhoverAnchor(anchor, 0)
fireEvent.mouseEnter(tooltip)
advanceTimers(150) // past clickable's 100ms hide-delay so the close timer fires
await flushMicrotasks()
expect(screen.getByRole('tooltip')).toBeInTheDocument()

const elem = screen.getByRole('tooltip')
expect(elem).toBeInTheDocument()
expect(elem).toHaveClass('react-tooltip__show')

fireEvent.mouseLeave(tooltip)
await flushMicrotasks()
Expand Down