Skip to content

Commit

Permalink
feat: support for disabled tooltip callback
Browse files Browse the repository at this point in the history
  • Loading branch information
nareshpingale committed Jul 21, 2024
1 parent 143221a commit 962a660
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const Tooltip = ({
position,
afterShow,
afterHide,
disableTooltip,
// props handled by controller
content,
contentWrapperRef,
Expand Down Expand Up @@ -459,6 +460,9 @@ const Tooltip = ({
const elementRefs = new Set(anchorRefs)

anchorsBySelect.forEach((anchor) => {
if(disableTooltip?.(anchor)){
return;
}
elementRefs.add({ current: anchor })
})

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 @@ -152,6 +152,7 @@ export interface ITooltip {
setIsOpen?: (value: boolean) => void
afterShow?: () => void
afterHide?: () => void
disableTooltip?: (anchorRef: HTMLElement | null) => boolean
activeAnchor: HTMLElement | null
setActiveAnchor: (anchor: HTMLElement | null) => void
border?: CSSProperties['border']
Expand Down
2 changes: 2 additions & 0 deletions src/components/TooltipController/TooltipController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
setIsOpen,
afterShow,
afterHide,
disableTooltip,
role = 'tooltip',
}: ITooltipController,
ref,
Expand Down Expand Up @@ -370,6 +371,7 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
setIsOpen,
afterShow,
afterHide,
disableTooltip,
activeAnchor,
setActiveAnchor: (anchor: HTMLElement | null) => setActiveAnchor(anchor),
role,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface ITooltipController {
setIsOpen?: (value: boolean) => void
afterShow?: () => void
afterHide?: () => void
disableTooltip?: (anchorRef: HTMLElement | null) => boolean
role?: React.AriaRole
}

Expand Down

0 comments on commit 962a660

Please sign in to comment.