diff --git a/packages/react/src/components/tooltip/tooltip.tsx b/packages/react/src/components/tooltip/tooltip.tsx index 7105f2abd3..654fdbea73 100644 --- a/packages/react/src/components/tooltip/tooltip.tsx +++ b/packages/react/src/components/tooltip/tooltip.tsx @@ -5,6 +5,7 @@ import { PropsWithChildren, useCallback, useEffect, + useRef, useMemo, useState, } from 'react'; @@ -234,6 +235,7 @@ export const Tooltip: FunctionComponent> = ({ const [isClicked, setIsClicked] = useState(false); const currentLabel = isClicked ? (confirmationLabel ?? label) : label; const tooltipVariant = (mode === 'confirm' && isClicked) ? 'success' : 'normal'; + const prevLabel = useRef(currentLabel); const getTooltipTriggerType = useCallback((): TriggerType | null => { if (disabled) { @@ -254,6 +256,11 @@ export const Tooltip: FunctionComponent> = ({ delayShow: delayed ? titleDelay : undefined, }, { modifiers }); + if (prevLabel.current !== currentLabel) { + prevLabel.current = currentLabel; + popperTooltip?.update?.(); + } + const openTooltip = useCallback((): void => { if (delayed && !disabled) { setTooltipTimeout(() => setTimeout(() => setControlledTooltipOpen(true), titleDelay));