From 4d841b776eadd468dfd8cd63c0b0a17804c51f97 Mon Sep 17 00:00:00 2001 From: Mike Perrotti Date: Thu, 14 Dec 2023 07:25:13 -0500 Subject: [PATCH] Let aria-required be undefined if not passed (#4058) * skips rendering aria-required attr on inputs if it 'required' prop is undefined * adds changeset * Update light-frogs-leave.md --------- Co-authored-by: Siddharth Kshetrapal --- .changeset/light-frogs-leave.md | 7 ++++ src/TextInput/TextInput.tsx | 2 +- src/Textarea/Textarea.tsx | 2 +- .../__snapshots__/Autocomplete.test.tsx.snap | 7 ---- .../__snapshots__/TextInput.test.tsx.snap | 33 ------------------- .../__snapshots__/Textarea.test.tsx.snap | 1 - 6 files changed, 9 insertions(+), 43 deletions(-) create mode 100644 .changeset/light-frogs-leave.md diff --git a/.changeset/light-frogs-leave.md b/.changeset/light-frogs-leave.md new file mode 100644 index 00000000000..4351a1c1c5a --- /dev/null +++ b/.changeset/light-frogs-leave.md @@ -0,0 +1,7 @@ +--- +'@primer/react': patch +--- + +TextInput, Textarea: Does not pass `aria-required` attribute to input or textarea if it is undefined. This fixes some tests that were breaking in dotcom. + + diff --git a/src/TextInput/TextInput.tsx b/src/TextInput/TextInput.tsx index 5250f510b6e..fe0848446ea 100644 --- a/src/TextInput/TextInput.tsx +++ b/src/TextInput/TextInput.tsx @@ -144,7 +144,7 @@ const TextInput = React.forwardRef( onFocus={handleInputFocus} onBlur={handleInputBlur} type={type} - aria-required={required ? 'true' : 'false'} + aria-required={required} {...inputProps} data-component="input" /> diff --git a/src/Textarea/Textarea.tsx b/src/Textarea/Textarea.tsx index 669e595c7d5..944d2715c25 100644 --- a/src/Textarea/Textarea.tsx +++ b/src/Textarea/Textarea.tsx @@ -92,7 +92,7 @@ const Textarea = React.forwardRef(