@@ -89,9 +89,6 @@ interface TooltipBaseProps {
8989 /**
9090 * Provide the label to be rendered inside of the Tooltip. The label will use
9191 * `aria-labelledby` and will fully describe the child node that is provided.
92- * If the child already has an `aria-label`, the tooltip will not apply
93- * `aria-labelledby`. If the child has its own `aria-labelledby`, that value
94- * will be kept. Otherwise, the tooltip will use its own ID to label the child.
9592 * This means that if you have text in the child node, that it will not be
9693 * announced to the screen reader.
9794 *
@@ -142,28 +139,13 @@ const Tooltip: TooltipComponent = React.forwardRef(
142139 const child = React . Children . only ( children ) ;
143140
144141 const {
145- 'aria-label' : ariaLabel ,
146142 'aria-labelledby' : ariaLabelledBy ,
147143 'aria-describedby' : ariaDescribedBy ,
148144 } = child ?. props ?? { } ;
149145
150146 const hasLabel = ! ! label ;
151- const hasAriaLabel =
152- typeof ariaLabel === 'string' ? ariaLabel . trim ( ) !== '' : false ;
153-
154- // An `aria-label` takes precedence over `aria-describedby`, but when it's
155- // needed and the user doesn't specify one, the fallback `id` is used.
156- const labelledBy = hasAriaLabel
157- ? undefined
158- : hasLabel
159- ? ( ariaLabelledBy ?? id )
160- : undefined ;
161-
162- // If `aria-label` is present, use any provided `aria-describedby`.
163- // If not, fallback to child's `aria-describedby` or the tooltip `id` if needed.
164- const describedBy = hasAriaLabel
165- ? ariaDescribedBy
166- : ( ariaDescribedBy ?? ( ! hasLabel && ! ariaLabelledBy ? id : undefined ) ) ;
147+ const labelledBy = ariaLabelledBy ?? ( hasLabel ? id : undefined ) ;
148+ const describedBy = ariaDescribedBy ?? ( ! hasLabel ? id : undefined ) ;
167149
168150 const triggerProps = {
169151 onFocus : ( ) => ! focusByMouse && setOpen ( true ) ,
0 commit comments