Skip to content

Commit

Permalink
comment out aria-label warning for now
Browse files Browse the repository at this point in the history
  • Loading branch information
broccolinisoup committed May 16, 2023
1 parent 6e66e50 commit 9d151e8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,17 @@ export const Tooltip = ({
'The `Tooltip` component expects a single React element that contains interactive content. Consider using a `<button>` or equivalent interactive element instead.',
)
// If the tooltip is used for labelling the interactive element, the trigger element or any of its children should not have aria-label
if (type === 'label') {
const hasAriaLabel = triggerRef.current.hasAttribute('aria-label')
const hasAriaLabelInChildren = Array.from(triggerRef.current.childNodes).some(
child => child instanceof HTMLElement && child.hasAttribute('aria-label'),
)
warning(
hasAriaLabel || hasAriaLabelInChildren,
'The label type `Tooltip` is going to be used here to label the trigger element. Please remove the aria-label from the trigger element.',
)
}
// Commenting out this code for now to see the non-interactive element usages
// if (type === 'label') {
// const hasAriaLabel = triggerRef.current.hasAttribute('aria-label')
// const hasAriaLabelInChildren = Array.from(triggerRef.current.childNodes).some(
// child => child instanceof HTMLElement && child.hasAttribute('aria-label'),
// )
// warning(
// hasAriaLabel || hasAriaLabelInChildren,
// 'The label type `Tooltip` is going to be used here to label the trigger element. Please remove the aria-label from the trigger element.',
// )
// }
}
})
}
Expand Down

0 comments on commit 9d151e8

Please sign in to comment.