@rjsf/core 6.5.1 → 6.5.2

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.esm.js CHANGED
@@ -781,10 +781,12 @@ function ArrayField(props) {
781
781
  );
782
782
  const handleChange = useCallback(
783
783
  (value, path, newErrorSchema, id) => {
784
+ const lastPathIsItemIndex = typeof path.at(-1) === "number";
784
785
  onChange(
785
786
  // We need to treat undefined items as nulls to have validation.
786
787
  // See https://github.com/tdegrunt/jsonschema/issues/206
787
- value === void 0 ? null : value,
788
+ // Only set to null for array items, and not for object properties within array items
789
+ lastPathIsItemIndex && value === void 0 ? null : value,
788
790
  path,
789
791
  newErrorSchema,
790
792
  id
@@ -4752,7 +4754,8 @@ var Form = class extends Component3 {
4752
4754
  const { newErrorSchema } = this.pendingChanges[0];
4753
4755
  const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, removeEmptyOptionalObjects } = this.props;
4754
4756
  const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
4755
- let { customErrors, errorSchema: originalErrorSchema } = this.state;
4757
+ let { customErrors } = this.state;
4758
+ let mergeBaseErrorSchema = schemaValidationErrorSchema;
4756
4759
  const rootPathId = fieldPathId.path[0] || "";
4757
4760
  const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
4758
4761
  let retrievedSchema = this.state.retrievedSchema;
@@ -4795,9 +4798,10 @@ var Form = class extends Component3 {
4795
4798
  const oldValidationError = !isRootPath ? _get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
4796
4799
  if (!_isEmpty(oldValidationError)) {
4797
4800
  if (!isRootPath) {
4798
- _set(originalErrorSchema, path, newErrorSchema);
4801
+ mergeBaseErrorSchema = _cloneDeep(schemaValidationErrorSchema);
4802
+ _set(mergeBaseErrorSchema, path, newErrorSchema);
4799
4803
  } else {
4800
- originalErrorSchema = newErrorSchema;
4804
+ mergeBaseErrorSchema = newErrorSchema;
4801
4805
  }
4802
4806
  } else {
4803
4807
  if (!customErrors) {
@@ -4819,7 +4823,7 @@ var Form = class extends Component3 {
4819
4823
  const liveValidation = this.liveValidate(
4820
4824
  schema,
4821
4825
  schemaUtils,
4822
- originalErrorSchema,
4826
+ mergeBaseErrorSchema,
4823
4827
  newFormData,
4824
4828
  extraErrors,
4825
4829
  customErrors,
@@ -4827,7 +4831,7 @@ var Form = class extends Component3 {
4827
4831
  );
4828
4832
  state = { formData: newFormData, ...liveValidation, customErrors };
4829
4833
  } else if (!noValidate && newErrorSchema) {
4830
- const mergedErrors = this.mergeErrors({ errorSchema: originalErrorSchema, errors }, extraErrors, customErrors);
4834
+ const mergedErrors = this.mergeErrors({ errorSchema: mergeBaseErrorSchema, errors }, extraErrors, customErrors);
4831
4835
  state = {
4832
4836
  formData: newFormData,
4833
4837
  ...mergedErrors,