Skip to content

Commit adf51a5

Browse files
author
VilleWennerlund
committed
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.
1 parent 08bfc6f commit adf51a5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/components/Tooltip/Tooltip.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const Tooltip = ({
6868
border,
6969
opacity,
7070
arrowColor,
71+
enforceDelayShow = false,
7172
role = 'tooltip',
7273
}: ITooltip) => {
7374
const tooltipRef = useRef<HTMLElement>(null)
@@ -259,7 +260,7 @@ const Tooltip = ({
259260
const handleShowTooltipDelayed = (delay = delayShow) => {
260261
clearTimeoutRef(tooltipShowDelayTimerRef)
261262

262-
if (rendered) {
263+
if (rendered && !enforceDelayShow) {
263264
// if the tooltip is already rendered, ignore delay
264265
handleShow(true)
265266
return

src/components/Tooltip/TooltipTypes.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,6 @@ export interface ITooltip {
158158
border?: CSSProperties['border']
159159
opacity?: CSSProperties['opacity']
160160
arrowColor?: CSSProperties['backgroundColor']
161+
enforceDelayShow?: boolean
161162
role?: React.AriaRole
162163
}

0 commit comments

Comments
 (0)