Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
added aria-invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Sugan G authored and Sugan G committed Nov 30, 2023
1 parent b4468b1 commit d7ec175
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/terra-form-field/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Added
* Added `aria-invalid` for invalid entry.

## 4.31.0 - (November 13, 2023)

* Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/terra-form-field/src/Field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const Field = (props) => {
if ((required || isInvalid) && child && (child.type.isInput || child.type.isSelect || child.type.isTextarea)) {
return React.cloneElement(child, {
...required && { required: true },
...isInvalid && { isInvalid: true },
...isInvalid && { isInvalid: true, 'aria-invalid': true },
});
}
return child;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1562,11 +1562,13 @@ exports[`should render an invalid and required field with a Select 1`] = `
</label>
</div>
<Select
aria-invalid={true}
isInvalid={true}
key=".0"
required={true}
>
<select
aria-invalid={true}
invalid="true"
required={true}
/>
Expand Down Expand Up @@ -1707,11 +1709,13 @@ exports[`should render an invalid and required field with a Textarea 1`] = `
</label>
</div>
<Textarea
aria-invalid={true}
isInvalid={true}
key=".0"
required={true}
>
<textarea
aria-invalid={true}
invalid="true"
required={true}
/>
Expand Down Expand Up @@ -1852,11 +1856,13 @@ exports[`should render an invalid and required field with an Input 1`] = `
</label>
</div>
<Input
aria-invalid={true}
isInvalid={true}
key=".0"
required={true}
>
<input
aria-invalid={true}
invalid="true"
required={true}
/>
Expand Down Expand Up @@ -1991,10 +1997,12 @@ exports[`should render an invalid field with a Select 1`] = `
</label>
</div>
<Select
aria-invalid={true}
isInvalid={true}
key=".0"
>
<select
aria-invalid={true}
invalid="true"
/>
</Select>
Expand Down Expand Up @@ -2128,10 +2136,12 @@ exports[`should render an invalid field with an Input 1`] = `
</label>
</div>
<Input
aria-invalid={true}
isInvalid={true}
key=".0"
>
<input
aria-invalid={true}
invalid="true"
/>
</Input>
Expand Down Expand Up @@ -2265,10 +2275,12 @@ exports[`should render an invalid field with an Textarea 1`] = `
</label>
</div>
<Textarea
aria-invalid={true}
isInvalid={true}
key=".0"
>
<textarea
aria-invalid={true}
invalid="true"
/>
</Textarea>
Expand Down

0 comments on commit d7ec175

Please sign in to comment.