Skip to content

Commit 4b823ff

Browse files
authored
Remove redundant aria-label attribute from TextInput.Action (#4354)
* remove aria-label attribute from TextInput.Action * update snapshot * Create mighty-pears-deny.md
1 parent 1610a15 commit 4b823ff

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

.changeset/mighty-pears-deny.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
TextInput: Remove redundant `aria-label` attribute from `TextInput.Action` when it already has an `aria-labelledby`.

packages/react/src/__tests__/__snapshots__/TextInput.test.tsx.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,6 @@ exports[`TextInput renders trailingAction icon button 1`] = `
21772177
className="c3 TextInput-action"
21782178
>
21792179
<button
2180-
aria-label="Icon label"
21812180
aria-labelledby=":r1:"
21822181
className="c4"
21832182
data-block={null}

packages/react/src/internal/components/TextInputInnerAction.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,8 @@ const TextInputAction = forwardRef<HTMLButtonElement, TextInputActionProps>(
9696
<Box as="span" className="TextInput-action" marginLeft={1} marginRight={1} lineHeight="0">
9797
{icon && !children ? (
9898
<Tooltip direction={tooltipDirection ?? 's'} text={ariaLabel ?? ''} type="label">
99-
<IconButton
100-
variant={variant}
101-
type="button"
102-
icon={icon}
103-
size="small"
104-
sx={sx}
105-
{...rest}
106-
aria-label={ariaLabel as unknown as string}
107-
aria-labelledby={undefined}
108-
ref={forwardedRef}
109-
/>
99+
{/* @ts-ignore we intentionally do add aria-label to IconButton because Tooltip v2 adds an aria-labelledby instead. */}
100+
<IconButton variant={variant} type="button" icon={icon} size="small" sx={sx} {...rest} ref={forwardedRef} />
110101
</Tooltip>
111102
) : (
112103
<ConditionalTooltip aria-label={ariaLabel}>

0 commit comments

Comments
 (0)