Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ErrorMessage can not be displayed in two expression field. #2278

Merged
merged 3 commits into from
Mar 17, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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