Skip to content

Commit 45928b6

Browse files
committed
fix: core test and error message when formData is a string
not cleared
1 parent 4339d05 commit 45928b6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/core/src/components/Form.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ export default class Form<
319319
if (!deepEquals(this.props, prevProps)) {
320320
const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
321321
const isSchemaChanged = !deepEquals(prevProps.schema, this.props.schema);
322-
const isFormDataChanged = formDataChangedFields.length > 0;
322+
// When formData is not an object, getChangedFields returns an empty array.
323+
// In this case, deepEquals is most needed to check again.
324+
const isFormDataChanged =
325+
formDataChangedFields.length > 0 || !deepEquals(prevProps.formData, this.props.formData);
323326
const nextState = this.getStateFromProps(
324327
this.props,
325328
this.props.formData,

packages/core/test/Form.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,8 +4489,8 @@ describe('Form omitExtraData and liveOmit', () => {
44894489
// // error should still be present.
44904490
errors = node.querySelectorAll('.error-detail');
44914491
// screen.debug();
4492-
expect(errors).to.have.lengthOf(1);
4493-
expect(errors[0].textContent).to.be.eql("must have required property 'input'");
4492+
// change formData and make sure the error disappears.
4493+
expect(errors).to.have.lengthOf(0);
44944494

44954495
// trigger programmatic validation again and make sure the error disappears.
44964496
act(() => {

0 commit comments

Comments
 (0)