Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for disabled tooltip callback #1211

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
gabrieljablonski marked this conversation as resolved.
Show resolved Hide resolved
// 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;
}
danielbarion marked this conversation as resolved.
Show resolved Hide resolved
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
Loading