diff --git a/.changeset/grumpy-shirts-march.md b/.changeset/grumpy-shirts-march.md new file mode 100644 index 000000000000..6707df901665 --- /dev/null +++ b/.changeset/grumpy-shirts-march.md @@ -0,0 +1,5 @@ +--- +"@primer/react": patch +--- + +Bugfix: `aria-invalid` is overriden in TextInput diff --git a/packages/react/src/TextInput/TextInput.tsx b/packages/react/src/TextInput/TextInput.tsx index 0f7c445086b2..6c75f6d033c6 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} /> { it('should render a password input', () => { expect(render()).toMatchSnapshot() }) + + it('should not override prop aria-invalid', () => { + const onChange = jest.fn() + const {getByRole} = HTMLRender() + expect(getByRole('textbox')).toHaveAttribute('aria-invalid', 'true') + }) })