Skip to content

Commit 51fd344

Browse files
committed
Tooltip: do not add the aria-describedby attribute to the anchor
1 parent b06549d commit 51fd344

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

packages/components/src/tooltip/index.tsx

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* External dependencies
33
*/
44
import * as Ariakit from '@ariakit/react';
5-
import { useStoreState } from '@ariakit/react';
65
import clsx from 'clsx';
76

87
/**
@@ -14,7 +13,6 @@ import {
1413
useContext,
1514
createContext,
1615
forwardRef,
17-
cloneElement,
1816
} from '@wordpress/element';
1917
import deprecated from '@wordpress/deprecated';
2018

@@ -94,7 +92,6 @@ function UnforwardedTooltip(
9492
placement: computedPlacement,
9593
showTimeout: delay,
9694
} );
97-
const mounted = useStoreState( tooltipStore, 'mounted' );
9895

9996
if ( isNestedInTooltip ) {
10097
return isOnlyChild ? (
@@ -104,31 +101,12 @@ function UnforwardedTooltip(
104101
);
105102
}
106103

107-
// TODO: this is a temporary workaround to minimize the effects of the
108-
// Ariakit upgrade. Ariakit doesn't pass the `aria-describedby` prop to
109-
// the tooltip anchor anymore since 0.4.0, so we need to add it manually.
110-
// The `aria-describedby` attribute is added only if the anchor doesn't have
111-
// one already, and if the tooltip text is not the same as the anchor's
112-
// `aria-label`
113-
// See: https://github.com/WordPress/gutenberg/pull/64066
114-
// See: https://github.com/WordPress/gutenberg/pull/65989
115-
function addDescribedById( element: React.ReactElement ) {
116-
return describedById &&
117-
mounted &&
118-
element.props[ 'aria-describedby' ] === undefined &&
119-
element.props[ 'aria-label' ] !== text
120-
? cloneElement( element, { 'aria-describedby': describedById } )
121-
: element;
122-
}
123-
124104
return (
125105
<TooltipInternalContext.Provider value={ CONTEXT_VALUE }>
126106
<Ariakit.TooltipAnchor
127107
onClick={ hideOnClick ? tooltipStore.hide : undefined }
128108
store={ tooltipStore }
129-
render={
130-
isOnlyChild ? addDescribedById( children ) : undefined
131-
}
109+
render={ isOnlyChild ? children : undefined }
132110
ref={ ref }
133111
>
134112
{ isOnlyChild ? undefined : children }

0 commit comments

Comments
 (0)