From 058ee7314d455dba4b7790b8c3edb67f291cbdaf Mon Sep 17 00:00:00 2001 From: Pavithra Kodmad Date: Wed, 6 Mar 2024 21:58:05 -0800 Subject: [PATCH 1/4] Add failing test --- packages/react/src/__tests__/TextInput.test.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react/src/__tests__/TextInput.test.tsx b/packages/react/src/__tests__/TextInput.test.tsx index 65a70b52cd5..67810e451e4 100644 --- a/packages/react/src/__tests__/TextInput.test.tsx +++ b/packages/react/src/__tests__/TextInput.test.tsx @@ -230,4 +230,9 @@ describe('TextInput', () => { it('should render a password input', () => { expect(render()).toMatchSnapshot() }) + + it('should not override prop aria-invalid', () => { + const {getByRole} = HTMLRender() + expect(getByRole('textinput')).toHaveAttribute('aria-invalid', 'true') + }) }) From e81b76a5641922e1c4ee47b78999f5e89c843068 Mon Sep 17 00:00:00 2001 From: Pavithra Kodmad Date: Wed, 6 Mar 2024 22:00:55 -0800 Subject: [PATCH 2/4] Add failing test --- packages/react/src/__tests__/TextInput.test.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react/src/__tests__/TextInput.test.tsx b/packages/react/src/__tests__/TextInput.test.tsx index 67810e451e4..78d18969e73 100644 --- a/packages/react/src/__tests__/TextInput.test.tsx +++ b/packages/react/src/__tests__/TextInput.test.tsx @@ -232,7 +232,8 @@ describe('TextInput', () => { }) it('should not override prop aria-invalid', () => { - const {getByRole} = HTMLRender() - expect(getByRole('textinput')).toHaveAttribute('aria-invalid', 'true') + const onChange = jest.fn() + const {getByRole} = HTMLRender() + expect(getByRole('textbox')).toHaveAttribute('aria-invalid', 'true') }) }) From 594780cf412abf515ecece00a88a01fd2f5d9056 Mon Sep 17 00:00:00 2001 From: Pavithra Kodmad Date: Wed, 6 Mar 2024 22:01:02 -0800 Subject: [PATCH 3/4] Add fix --- packages/react/src/TextInput/TextInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/TextInput/TextInput.tsx b/packages/react/src/TextInput/TextInput.tsx index 0f7c445086b..6c75f6d033c 100644 --- a/packages/react/src/TextInput/TextInput.tsx +++ b/packages/react/src/TextInput/TextInput.tsx @@ -147,9 +147,9 @@ const TextInput = React.forwardRef( onBlur={handleInputBlur} type={type} aria-required={required} + aria-invalid={validationStatus === 'error' ? 'true' : undefined} {...inputProps} data-component="input" - aria-invalid={validationStatus === 'error' ? 'true' : undefined} /> Date: Thu, 7 Mar 2024 17:05:07 +1100 Subject: [PATCH 4/4] Create grumpy-shirts-march.md --- .changeset/grumpy-shirts-march.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/grumpy-shirts-march.md diff --git a/.changeset/grumpy-shirts-march.md b/.changeset/grumpy-shirts-march.md new file mode 100644 index 00000000000..6707df90166 --- /dev/null +++ b/.changeset/grumpy-shirts-march.md @@ -0,0 +1,5 @@ +--- +"@primer/react": patch +--- + +Bugfix: `aria-invalid` is overriden in TextInput