Skip to content

Commit

Permalink
Added enforceDelayShow prop.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
VilleWennerlund committed Nov 27, 2024
1 parent 08bfc6f commit adf51a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Tooltip = ({
border,
opacity,
arrowColor,
enforceDelayShow = false,
role = 'tooltip',
}: ITooltip) => {
const tooltipRef = useRef<HTMLElement>(null)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/components/Tooltip/TooltipTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,6 @@ export interface ITooltip {
border?: CSSProperties['border']
opacity?: CSSProperties['opacity']
arrowColor?: CSSProperties['backgroundColor']
enforceDelayShow?: boolean
role?: React.AriaRole
}

0 comments on commit adf51a5

Please sign in to comment.