From cb321f05b95c53ea15bfcd18a0d2b0df60bf67d1 Mon Sep 17 00:00:00 2001 From: Armagan Ersoz Date: Thu, 11 Jul 2024 12:21:13 +1000 Subject: [PATCH 1/2] Remove the external Tooltip from textinputinneraction --- .../components/TextInputInnerAction.tsx | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/react/src/internal/components/TextInputInnerAction.tsx b/packages/react/src/internal/components/TextInputInnerAction.tsx index 93ce1b7ba93..c4aa909d767 100644 --- a/packages/react/src/internal/components/TextInputInnerAction.tsx +++ b/packages/react/src/internal/components/TextInputInnerAction.tsx @@ -79,7 +79,16 @@ const ConditionalTooltip: React.FC< const TextInputAction = forwardRef( ( - {'aria-label': ariaLabel, tooltipDirection, children, icon, sx: sxProp, variant = 'invisible', ...rest}, + { + 'aria-label': ariaLabel, + 'aria-labelledby': ariaLabelledBy, + tooltipDirection, + children, + icon, + sx: sxProp, + variant = 'invisible', + ...rest + }, forwardedRef, ) => { const sx = @@ -92,13 +101,28 @@ const TextInputAction = forwardRef( console.warn('Use the `aria-label` prop to provide an accessible label for assistive technology') } + const accessibleLabel = ariaLabel + ? {'aria-label': ariaLabel} + : ariaLabelledBy + ? {'aria-labelledby': ariaLabelledBy} + : { + 'aria-label': '', + } + return ( - {icon && !children ? ( - - {/* @ts-ignore we intentionally do add aria-label to IconButton because Tooltip v2 adds an aria-labelledby instead. */} - - + {icon && !children && ariaLabel ? ( + ) : (