From fb2da5152cded73d34d2650330b06ea487a7ce35 Mon Sep 17 00:00:00 2001 From: Adriana Babakanian Date: Thu, 25 May 2023 12:45:37 -0400 Subject: [PATCH] Remove aria-hidden=true from spans with required asterisk (#3320) * Remove aria-hidden=true from spans with required asterisk * Create pink-beds-fetch.md --------- Co-authored-by: Cole Bemis --- .changeset/pink-beds-fetch.md | 5 +++++ src/__tests__/deprecated/InputField.test.tsx | 3 ++- src/internal/components/InputLabel.tsx | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/pink-beds-fetch.md diff --git a/.changeset/pink-beds-fetch.md b/.changeset/pink-beds-fetch.md new file mode 100644 index 00000000000..5400fd391fa --- /dev/null +++ b/.changeset/pink-beds-fetch.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +Remove `aria-hidden=true` from `span`s with required asterisk diff --git a/src/__tests__/deprecated/InputField.test.tsx b/src/__tests__/deprecated/InputField.test.tsx index 71e8d6c0273..5a6fcae7cef 100644 --- a/src/__tests__/deprecated/InputField.test.tsx +++ b/src/__tests__/deprecated/InputField.test.tsx @@ -6,6 +6,7 @@ import InputField from '../../deprecated/InputField' expect.extend(toHaveNoViolations) const TEXTINPUTFIELD_LABEL_TEXT = 'Name' +const TEXTINPUTFIELD_LABEL_TEXT_WITH_ASTERISK = 'Name *' const TEXTINPUTFIELD_CAPTION_TEXT = 'Hint: your first name' const TEXTINPUTFIELD_SUCCESS_TEXT = 'This name is valid' const TEXTINPUTFIELD_ERROR_TEXT = 'This name is invalid' @@ -66,7 +67,7 @@ describe('InputField', () => { , ) - const input = getByRole('textbox', {name: TEXTINPUTFIELD_LABEL_TEXT}) + const input = getByRole('textbox', {name: TEXTINPUTFIELD_LABEL_TEXT_WITH_ASTERISK}) expect(input.getAttribute('required')).not.toBeNull() }) diff --git a/src/internal/components/InputLabel.tsx b/src/internal/components/InputLabel.tsx index 2b26755bb3c..1117c0f79bf 100644 --- a/src/internal/components/InputLabel.tsx +++ b/src/internal/components/InputLabel.tsx @@ -55,7 +55,7 @@ const InputLabel: React.FC> = ({ {required ? ( {children} - + * ) : ( children