diff --git a/packages/react/src/components/Field/FieldFeedback.tsx b/packages/react/src/components/Field/FieldFeedback.tsx index 80906a771..f07795ab5 100644 --- a/packages/react/src/components/Field/FieldFeedback.tsx +++ b/packages/react/src/components/Field/FieldFeedback.tsx @@ -14,7 +14,12 @@ export const FieldFeedback: React.FunctionComponent = ({ }: FieldFeedbackProps) => { const Errors = React.useMemo(() => { if (!errors || !errors.length) return null; - return ( + + return errors.map((err) =>
  • {err}
  • ); + }, [errors]); + + return ( +
    - ); - }, [errors, errorsClass, errorsId, liveErrors]); - - return ( -
    - {Errors} {children}
    ); diff --git a/packages/react/src/components/TextField/index.stories.tsx b/packages/react/src/components/TextField/index.stories.tsx index aece4467c..bc377d401 100644 --- a/packages/react/src/components/TextField/index.stories.tsx +++ b/packages/react/src/components/TextField/index.stories.tsx @@ -16,6 +16,7 @@ export default { control: { type: 'range', min: 5, step: 1 }, }, validateOnChange: { control: { type: 'boolean' } }, + validateOnDOMChange: { control: { type: 'boolean' } }, }, } as Meta; diff --git a/packages/react/src/components/TextField/index.test.tsx b/packages/react/src/components/TextField/index.test.tsx index 854474e39..ada792841 100644 --- a/packages/react/src/components/TextField/index.test.tsx +++ b/packages/react/src/components/TextField/index.test.tsx @@ -63,7 +63,7 @@ test('validation errors are not rendered in the field feedback on DOM `input` by await user.keyboard('abc'); const errList = screen.queryByRole('list', { name: 'Errors' }); - t.falsy(errList); + t.falsy(errList?.children.length); }); test('validation errors are rendered in the field feedback on DOM `input` when `validateOnChange` is true', async (t) => { @@ -80,7 +80,7 @@ test('validation errors are rendered in the field feedback on DOM `input` when ` await user.keyboard('abc'); const errList = screen.queryByRole('list', { name: 'Errors' }); - t.truthy(errList); + t.truthy(errList?.children); }); test('the error list is not rendered when there are no errors', async (t) => { @@ -95,7 +95,7 @@ test('the error list is not rendered when there are no errors', async (t) => { await user.tab(); const errList = screen.queryByRole('list', { name: 'Errors' }); - t.falsy(errList); + t.falsy(errList?.children.length); }); test('invalid input is reflected in both constraint validation and in ARIA', async (t) => {