diff --git a/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/twoSettingFields.tsx b/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/twoSettingFields.tsx index 2f6f84a54b..e66ae4d02d 100644 --- a/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/twoSettingFields.tsx +++ b/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/twoSettingFields.tsx @@ -21,10 +21,12 @@ interface TwoSettingFieldsProps extends FieldProps { } export const TwoSettingFields: React.FC = props => { const { fields, formData, idSchema, getSchema, onChange, errorSchema } = props; + const errs: (JSX.Element | string | undefined)[] = []; const [errorMessage, setErrorMessage] = useState(); - 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 ( @@ -40,7 +42,9 @@ export const TwoSettingFields: React.FC = props => { formContext={props.formContext} rawErrors={errorSchema[settingField.name] && errorSchema[settingField.name].__errors} hiddenErrMessage={true} - onValidate={onValidate} + onValidate={errMsg => { + onValidate(index, errMsg); + }} /> ))}