Skip to content

Commit

Permalink
reset fileds after unmount form component
Browse files Browse the repository at this point in the history
ref #128
  • Loading branch information
afc163 committed Dec 23, 2017
1 parent db23161 commit ed5bb4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/createBaseForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function createBaseForm(option = {}, mixins = []) {
);
}

this.recoverClearedField(name);
delete this.clearedFieldMetaCache[name];

const fieldOption = {
name,
Expand Down
14 changes: 7 additions & 7 deletions tests/dynamic-binding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ describe('binding dynamic fields without any errors', () => {
expect(form.getFieldValue('input1')).toBe(undefined);
expect(form.getFieldValue('input2')).toBe(undefined);
wrapper.setProps({ mode: true });
expect(wrapper.find('#text1').getDOMNode().value).toBe('123');
expect(wrapper.find('#text2').getDOMNode().value).toBe('456');
expect(form.getFieldValue('input1')).toBe('123');
expect(form.getFieldValue('input2')).toBe('456');
expect(wrapper.find('#text1').getDOMNode().value).toBe('');
expect(wrapper.find('#text2').getDOMNode().value).toBe('');
expect(form.getFieldValue('input1')).toBe(undefined);
expect(form.getFieldValue('input2')).toBe(undefined);
wrapper.find('#text1').simulate('change', { target: { value: '789' } });
expect(wrapper.find('#text1').getDOMNode().value).toBe('789');
expect(wrapper.find('#text2').getDOMNode().value).toBe('456');
expect(wrapper.find('#text2').getDOMNode().value).toBe('');
expect(form.getFieldValue('input1')).toBe('789');
expect(form.getFieldValue('input2')).toBe('456');
expect(form.getFieldValue('input2')).toBe(undefined);
form.validateFields((errors, values) => {
expect(errors).toBe(null);
expect(values.input1).toBe('789');
expect(values.input2).toBe('456');
expect(values.input2).toBe(undefined);
done();
});
});
Expand Down

0 comments on commit ed5bb4e

Please sign in to comment.