Skip to content

Commit

Permalink
fix(react): fix TextField not reporting validation errors to Screen R…
Browse files Browse the repository at this point in the history
…eaders
  • Loading branch information
cafrias committed Dec 15, 2023
1 parent ce7e93d commit 3ee88fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/react/src/components/Field/FieldFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FieldFeedbackProps } from './types';

/** A container for field feedback. Use to display content based on field input. */
export const FieldFeedback: React.FunctionComponent<FieldFeedbackProps> = ({
errors,
errors = [],
liveErrors = true,
baseName = 'nds-field',
errorsClass = `${baseName}__errors`,
Expand All @@ -13,14 +13,15 @@ export const FieldFeedback: React.FunctionComponent<FieldFeedbackProps> = ({
id,
}: FieldFeedbackProps) => {
const Errors = React.useMemo(() => {
if (!errors || !errors.length) return null;
const hidden = !errors.length;
return (
<ul
className={errorsClass}
id={errorsId}
aria-label="Errors"
aria-live={(liveErrors) ? 'assertive' : undefined}
aria-atomic={(liveErrors) ? 'true' : undefined}
aria-hidden={hidden}
>
{ errors.map((err) => <li key={err}>{ err }</li>) }
</ul>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/TextField/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@testing-library/react';
import { TextField, TextFieldUncontrolled } from '.';

test.afterEach(cleanup);
test.afterEach.always(cleanup);

const noop = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
const defaultLabel = 'Text field';
Expand Down

0 comments on commit 3ee88fd

Please sign in to comment.