File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
packages/react/src/TooltipV2 Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -247,12 +247,21 @@ export const Tooltip = React.forwardRef(
247247 React . cloneElement ( child as React . ReactElement < TriggerPropsType > , {
248248 ref : triggerRef ,
249249 // If it is a type description, we use tooltip to describe the trigger
250- 'aria-describedby' :
251- type === 'description'
252- ? child . props [ 'aria-describedby' ]
253- ? `${ child . props [ 'aria-describedby' ] } ${ tooltipId } `
254- : tooltipId
255- : child . props [ 'aria-describedby' ] ,
250+ 'aria-describedby' : ( ( ) => {
251+ // If tooltip is not a description type, keep the original aria-describedby
252+ if ( type !== 'description' ) {
253+ return child . props [ 'aria-describedby' ]
254+ }
255+
256+ // If tooltip is a description type, append our tooltipId
257+ const existingDescribedBy = child . props [ 'aria-describedby' ]
258+ if ( existingDescribedBy ) {
259+ return `${ existingDescribedBy } ${ tooltipId } `
260+ }
261+
262+ // If no existing aria-describedby, use our tooltipId
263+ return tooltipId
264+ } ) ( ) ,
256265 // If it is a label type, we use tooltip to label the trigger
257266 'aria-labelledby' : type === 'label' ? tooltipId : child . props [ 'aria-labelledby' ] ,
258267 onBlur : ( event : React . FocusEvent ) => {
You can’t perform that action at this time.
0 commit comments