Skip to content
Closed
Changes from all commits
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
15 changes: 5 additions & 10 deletions packages/react/src/TooltipV2/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,14 @@ const positionToDirection: Record<string, TooltipDirection> = {
}

// The list is from GitHub's custom-axe-rules https://github.com/github/github/blob/master/app/assets/modules/github/axe-custom-rules.ts#L3
const interactiveElements = [
'a[href]',
'button:not(:disabled)',
'summary',
'select',
'input:not([type=hidden])',
'textarea',
]
const interactiveElements = ['a[href]', 'button', 'summary', 'select', 'input:not([type=hidden])', 'textarea']

const isInteractive = (element: HTMLElement) => {
return (
const notDisabled = !element.hasAttribute('disabled')
const interactive =
interactiveElements.some(selector => element.matches(selector)) ||
(element.hasAttribute('role') && element.getAttribute('role') === 'button')
)
return notDisabled && interactive
}
export const TooltipContext = React.createContext<{tooltipId?: string}>({})

Expand Down Expand Up @@ -249,6 +243,7 @@ export const Tooltip = React.forwardRef(
const hasInteractiveChild = Array.from(triggerChildren).some(child => {
return child instanceof HTMLElement && isInteractive(child)
})
// console.log('test logging', triggerRef.current, isTriggerInteractive, hasInteractiveChild)
invariant(
isTriggerInteractive || hasInteractiveChild,
'The `Tooltip` component expects a single React element that contains interactive content. Consider using a `<button>` or equivalent interactive element instead.',
Expand Down