Skip to content

🐛 - Fixes-Issue 1953 - DynamicForm required User Fields not checked before submit (Repo Rescuer Challenge) #1965

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

Merged
merged 2 commits into from
Mar 14, 2025
Merged
Changes from all 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
10 changes: 8 additions & 2 deletions src/controls/dynamicForm/dynamicField/DynamicField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -644,18 +644,20 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
const {
changedValue
} = this.state;

const { value, newValue, required,listItemId } = this.props;

if (listItemId !== undefined && listItemId !== null) {
if (newValue === undefined) {
return required && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue))
&& (value === undefined || value === '' || value === null || this.isEmptyArray(value)) ? strings.DynamicFormRequiredErrorMessage : null;
&& (value === undefined || value === '' || value === null || this.isEmptyArray(value)) || this.checkUserArrayIsEmpty(value)) ? strings.DynamicFormRequiredErrorMessage : null;
} else {
return required && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue)) ? strings.DynamicFormRequiredErrorMessage : null;
return required && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue)) || this.checkUserArrayIsEmpty(value)) ? strings.DynamicFormRequiredErrorMessage : null;
}
}

return null;

}

private getNumberErrorText = (): string => {
Expand Down Expand Up @@ -724,6 +726,10 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
return Array.isArray(value) && value.length === 0;
}

private checkUserArrayIsEmpty = (value): boolean => {
return Array.isArray(value) && value.every(item => item === "");
}

private MultiChoice_selection = (event: React.FormEvent<HTMLDivElement>, item: IDropdownOption): void => {
const {
changedValue
Expand Down