Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlong9278 committed Mar 16, 2020
1 parent ad6903d commit 23f02e9
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ interface TwoSettingFieldsProps extends FieldProps<MicrosoftInputDialog> {
}
export const TwoSettingFields: React.FC<TwoSettingFieldsProps> = props => {
const { fields, formData, idSchema, getSchema, onChange, errorSchema } = props;
const errs: (JSX.Element | string | undefined)[] = [];
const [errorMessage, setErrorMessage] = useState<JSX.Element | string | undefined>();

const onValidate = (err?: JSX.Element | string) => {
setErrorMessage(err);
const onValidate = (index: number, err?: JSX.Element | string | undefined) => {
errs[index] = err;
setErrorMessage(errs.find(err => err || null));
};

return (
Expand All @@ -40,7 +42,9 @@ export const TwoSettingFields: React.FC<TwoSettingFieldsProps> = props => {
formContext={props.formContext}
rawErrors={errorSchema[settingField.name] && errorSchema[settingField.name].__errors}
hiddenErrMessage={true}
onValidate={onValidate}
onValidate={errMsg => {
onValidate(index, errMsg);
}}
/>
</div>
))}
Expand Down

0 comments on commit 23f02e9

Please sign in to comment.