From adf51a53d950d70210d9cc04fb4ef5a9f8607e5c Mon Sep 17 00:00:00 2001 From: VilleWennerlund Date: Wed, 27 Nov 2024 14:32:53 +0100 Subject: [PATCH] Added enforceDelayShow prop. This will make the delayShow prop to always be enforced even if the tooltip instance is rendered. This can be used for when you only have one tooltip instance, but multiple tooltip anchors, and want it to always take the delayShow amount of time before it is shown. --- src/components/Tooltip/Tooltip.tsx | 3 ++- src/components/Tooltip/TooltipTypes.d.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx index 1471e930..19b18606 100644 --- a/src/components/Tooltip/Tooltip.tsx +++ b/src/components/Tooltip/Tooltip.tsx @@ -68,6 +68,7 @@ const Tooltip = ({ border, opacity, arrowColor, + enforceDelayShow = false, role = 'tooltip', }: ITooltip) => { const tooltipRef = useRef(null) @@ -259,7 +260,7 @@ const Tooltip = ({ const handleShowTooltipDelayed = (delay = delayShow) => { clearTimeoutRef(tooltipShowDelayTimerRef) - if (rendered) { + if (rendered && !enforceDelayShow) { // if the tooltip is already rendered, ignore delay handleShow(true) return diff --git a/src/components/Tooltip/TooltipTypes.d.ts b/src/components/Tooltip/TooltipTypes.d.ts index ee7fc42c..ddcd59fa 100644 --- a/src/components/Tooltip/TooltipTypes.d.ts +++ b/src/components/Tooltip/TooltipTypes.d.ts @@ -158,5 +158,6 @@ export interface ITooltip { border?: CSSProperties['border'] opacity?: CSSProperties['opacity'] arrowColor?: CSSProperties['backgroundColor'] + enforceDelayShow?: boolean role?: React.AriaRole }