Skip to content

Commit 2f77d32

Browse files
committed
chore(tooltip): update tooltip position on open
1 parent 4a60549 commit 2f77d32

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/lumx-react/src/components/tooltip/Tooltip.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, re
8181

8282
const [popperElement, setPopperElement] = useState<null | HTMLElement>(null);
8383
const [anchorElement, setAnchorElement] = useState<null | HTMLElement>(null);
84-
const { styles, attributes } = usePopper(anchorElement, popperElement, {
84+
const { styles, attributes, update } = usePopper(anchorElement, popperElement, {
8585
placement,
8686
modifiers: [
8787
{
@@ -104,6 +104,11 @@ export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, re
104104
ariaLinkMode: ariaLinkMode as any,
105105
});
106106

107+
// Update on open
108+
React.useEffect(() => {
109+
if (isOpen) update?.();
110+
}, [isOpen, update]);
111+
107112
const labelLines = label ? label.split('\n') : [];
108113

109114
const tooltipRef = useMergeRefs(ref, setPopperElement, onPopperMount);

0 commit comments

Comments
 (0)