Skip to content

Commit

Permalink
Tooltip: add aria-describedby to anchor only if not redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Oct 9, 2024
1 parent 6aad856 commit a2e7c44
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/components/src/tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ function UnforwardedTooltip(
// the tooltip anchor anymore since 0.4.0, so we need to add it manually.
// See: https://github.com/WordPress/gutenberg/pull/64066
function addDescribedById( element: React.ReactElement ) {
return describedById && mounted
return describedById &&
mounted &&
element.props[ 'aria-describedby' ] === undefined &&
element.props[ 'aria-label' ] !== text
? cloneElement( element, { 'aria-describedby': describedById } )
: element;
}
Expand Down

0 comments on commit a2e7c44

Please sign in to comment.