@rjsf/core 5.17.0 → 5.18.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
@@ -724,6 +724,7 @@ var ArrayField = class extends import_react.Component {
724
724
  uiSchema,
725
725
  title: fieldTitle,
726
726
  formContext,
727
+ errorSchema,
727
728
  rawErrors
728
729
  };
729
730
  const Template = (0, import_utils.getTemplate)("ArrayFieldTemplate", registry, uiOptions);
@@ -3465,10 +3466,16 @@ var Form = class extends import_react17.Component {
3465
3466
  */
3466
3467
  getSnapshotBeforeUpdate(prevProps, prevState) {
3467
3468
  if (!(0, import_utils39.deepEquals)(this.props, prevProps)) {
3469
+ const isSchemaChanged = !(0, import_utils39.deepEquals)(prevProps.schema, this.props.schema);
3470
+ const isFormDataChanged = !(0, import_utils39.deepEquals)(prevProps.formData, this.props.formData);
3468
3471
  const nextState = this.getStateFromProps(
3469
3472
  this.props,
3470
3473
  this.props.formData,
3471
- prevProps.schema !== this.props.schema ? void 0 : this.state.retrievedSchema
3474
+ // If the `schema` has changed, we need to update the retrieved schema.
3475
+ // Or if the `formData` changes, for example in the case of a schema with dependencies that need to
3476
+ // match one of the subSchemas, the retrieved schema must be updated.
3477
+ isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
3478
+ isSchemaChanged
3472
3479
  );
3473
3480
  const shouldUpdate = !(0, import_utils39.deepEquals)(nextState, prevState);
3474
3481
  return { nextState, shouldUpdate };
@@ -3505,9 +3512,11 @@ var Form = class extends import_react17.Component {
3505
3512
  *
3506
3513
  * @param props - The props passed to the `Form`
3507
3514
  * @param inputFormData - The new or current data for the `Form`
3515
+ * @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
3516
+ * @param isSchemaChanged - A flag indicating whether the schema has changed.
3508
3517
  * @returns - The new state for the `Form`
3509
3518
  */
3510
- getStateFromProps(props, inputFormData, retrievedSchema) {
3519
+ getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false) {
3511
3520
  const state = this.state || {};
3512
3521
  const schema = "schema" in props ? props.schema : this.props.schema;
3513
3522
  const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
@@ -3523,7 +3532,7 @@ var Form = class extends import_react17.Component {
3523
3532
  const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
3524
3533
  const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
3525
3534
  const getCurrentErrors = () => {
3526
- if (props.noValidate) {
3535
+ if (props.noValidate || isSchemaChanged) {
3527
3536
  return { errors: [], errorSchema: {} };
3528
3537
  } else if (!props.liveValidate) {
3529
3538
  return {