@rjsf/core 5.12.0 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -892,7 +892,6 @@ var import_react2 = require("react");
892
892
  var import_get2 = __toESM(require("lodash/get"));
893
893
  var import_isEmpty = __toESM(require("lodash/isEmpty"));
894
894
  var import_omit = __toESM(require("lodash/omit"));
895
- var import_unset = __toESM(require("lodash/unset"));
896
895
  var import_utils3 = require("@rjsf/utils");
897
896
  var import_jsx_runtime3 = require("react/jsx-runtime");
898
897
  var AnyOfField = class extends import_react2.Component {
@@ -1015,9 +1014,8 @@ var AnyOfField = class extends import_react2.Component {
1015
1014
  const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1016
1015
  let optionSchema;
1017
1016
  if (option) {
1018
- const { oneOf, anyOf, ...remaining } = schema;
1019
- (0, import_unset.default)(remaining, import_utils3.ADDITIONAL_PROPERTY_FLAG);
1020
- optionSchema = !(0, import_isEmpty.default)(remaining) ? (0, import_utils3.mergeSchemas)(remaining, option) : option;
1017
+ const { required } = schema;
1018
+ optionSchema = required ? (0, import_utils3.mergeSchemas)({ required }, option) : option;
1021
1019
  }
1022
1020
  const translateEnum = title ? import_utils3.TranslatableString.TitleOptionPrefix : import_utils3.TranslatableString.OptionPrefix;
1023
1021
  const translateParams = title ? [title] : [];
@@ -1096,7 +1094,7 @@ var import_get3 = __toESM(require("lodash/get"));
1096
1094
  var import_has = __toESM(require("lodash/has"));
1097
1095
  var import_isObject3 = __toESM(require("lodash/isObject"));
1098
1096
  var import_set2 = __toESM(require("lodash/set"));
1099
- var import_unset2 = __toESM(require("lodash/unset"));
1097
+ var import_unset = __toESM(require("lodash/unset"));
1100
1098
  var import_jsx_runtime5 = require("react/jsx-runtime");
1101
1099
  var ObjectField = class extends import_react4.Component {
1102
1100
  constructor() {
@@ -1142,7 +1140,7 @@ var ObjectField = class extends import_react4.Component {
1142
1140
  event.preventDefault();
1143
1141
  const { onChange, formData } = this.props;
1144
1142
  const copiedFormData = { ...formData };
1145
- (0, import_unset2.default)(copiedFormData, key);
1143
+ (0, import_unset.default)(copiedFormData, key);
1146
1144
  onChange(copiedFormData);
1147
1145
  };
1148
1146
  };
@@ -3561,13 +3559,14 @@ var Form = class extends import_react17.Component {
3561
3559
  */
3562
3560
  validateForm() {
3563
3561
  const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
3564
- const { formData } = this.state;
3562
+ const { formData, errors: prevErrors } = this.state;
3565
3563
  const schemaValidation = this.validate(formData);
3566
3564
  let errors = schemaValidation.errors;
3567
3565
  let errorSchema = schemaValidation.errorSchema;
3568
3566
  const schemaValidationErrors = errors;
3569
3567
  const schemaValidationErrorSchema = errorSchema;
3570
- if (errors.length > 0 || extraErrors && extraErrorsBlockSubmit) {
3568
+ const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
3569
+ if (hasError) {
3571
3570
  if (extraErrors) {
3572
3571
  const merged = (0, import_utils39.validationDataMerge)(schemaValidation, extraErrors);
3573
3572
  errorSchema = merged.errorSchema;
@@ -3595,9 +3594,15 @@ var Form = class extends import_react17.Component {
3595
3594
  }
3596
3595
  }
3597
3596
  );
3598
- return false;
3597
+ } else if (prevErrors.length > 0) {
3598
+ this.setState({
3599
+ errors: [],
3600
+ errorSchema: {},
3601
+ schemaValidationErrors: [],
3602
+ schemaValidationErrorSchema: {}
3603
+ });
3599
3604
  }
3600
- return true;
3605
+ return !hasError;
3601
3606
  }
3602
3607
  /** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
3603
3608
  * needed along with the submit button or any children of the form.