Skip to content

Commit 0070d38

Browse files
fix: hide tooltip when render returns falsy
1 parent 5911cab commit 0070d38

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/TooltipController/TooltipController.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,18 @@ const TooltipController = ({
201201
}, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect])
202202

203203
/**
204-
* content priority: children < renderContent or content < html
204+
* content priority: children < render or content < html
205205
* children should be lower priority so that it can be used as the "default" content
206206
*/
207207
let renderedContent: ChildrenType = children
208208
const contentWrapperRef = useRef<HTMLDivElement>(null)
209209
if (render) {
210-
renderedContent = (
210+
const rendered = render({ content: tooltipContent ?? null, activeAnchor }) as React.ReactNode
211+
renderedContent = rendered ? (
211212
<div ref={contentWrapperRef} className="react-tooltip-content-wrapper">
212-
{render({ content: tooltipContent ?? null, activeAnchor }) as React.ReactNode}
213+
{rendered}
213214
</div>
214-
)
215+
) : null
215216
} else if (tooltipContent) {
216217
renderedContent = tooltipContent
217218
}

0 commit comments

Comments
 (0)