Skip to content

Commit

Permalink
fix(input): add aria-invalid when an input has an error (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydaf authored Sep 29, 2023
1 parent 17dbbda commit ec26782
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/Input/InnerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const InnerInput = forwardRef<HTMLDivElement, InputWrapperProps & InputProps>(
size={size}
hasValue={hasValue || hasUncontrolledValue}
onChange={handleChange}
aria-invalid={rest.error}
/>
{label && (
<BoxedInputLabel htmlFor={id} size={size}>
Expand All @@ -64,6 +65,7 @@ const InnerInput = forwardRef<HTMLDivElement, InputWrapperProps & InputProps>(
size={size}
hasValue={hasValue || hasUncontrolledValue}
onChange={handleChange}
aria-invalid={rest.error}
/>
{label && (
<BottomLinedInputLabel htmlFor={id} size={size}>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Input/__snapshots__/Input.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ exports[`Input variant "bottom-lined" renders the error state 1`] = `
class="c0"
>
<input
aria-invalid="true"
class="c1 c2"
id="random"
type="text"
Expand Down Expand Up @@ -347,6 +348,7 @@ exports[`Input variant "bottom-lined" renders the error state with label and pla
class="c0"
>
<input
aria-invalid="true"
class="c1 c2"
id="random"
placeholder="FREE NOW"
Expand Down Expand Up @@ -1054,6 +1056,7 @@ exports[`Input variant "boxed" renders the error state 1`] = `
class="c0"
>
<input
aria-invalid="true"
class="c1 c2"
id="random"
type="text"
Expand Down Expand Up @@ -1208,6 +1211,7 @@ exports[`Input variant "boxed" renders the error state with label and placeholde
class="c0"
>
<input
aria-invalid="true"
class="c1 c2"
id="random"
placeholder="FREE NOW"
Expand Down

0 comments on commit ec26782

Please sign in to comment.