Skip to content

Commit

Permalink
fix: Fix an issue where the FieldArray was not showing validation err…
Browse files Browse the repository at this point in the history
…ors inside a Wizard (#911)
  • Loading branch information
jessieweiyi authored Jun 23, 2023
1 parent 4bab9ff commit 004c23e
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,30 @@ const FieldArray: FC<DataDrivenFormFieldProps> = ({ ...props }) => {
defaultItem,
'data-testid': testId = 'field-array',
controlId,
showError,
...rest
} = props;

const definition = useMemo(() => {
return fields.map((field: Field) => {
const { label, name, ...rest } = field;
const { label, name, ...fieldRest } = field;
return {
label: label,
control: (_item: any, itemIndex: number) => {
return renderForm([
{
...rest,
...fieldRest,
isReadOnly,
isDisabled,
showError,
name: `${input.name}[${itemIndex}].${name}`,
'data-testid': `${testId}[${itemIndex}].${name}`,
},
]);
},
};
});
}, [fields, renderForm, input.name, isReadOnly, isDisabled, testId]);
}, [fields, renderForm, input.name, isReadOnly, isDisabled, testId, showError]);

return (
<FieldArrayBase key={controlId} name={controlId} validate={arrayValidator}>
Expand Down

0 comments on commit 004c23e

Please sign in to comment.