diff --git a/src/Field.tsx b/src/Field.tsx index 964fff12..335ac16b 100644 --- a/src/Field.tsx +++ b/src/Field.tsx @@ -620,13 +620,13 @@ class Field extends React.Component implements F if (normalize) { newValue = normalize(newValue, value, getFieldsValue(true)); } - - dispatch({ - type: 'updateValue', - namePath, - value: newValue, - }); - + if (!isEqual(newValue, value)) { + dispatch({ + type: 'updateValue', + namePath, + value: newValue, + }); + } if (originTriggerFunc) { originTriggerFunc(...args); } diff --git a/tests/control.test.tsx b/tests/control.test.tsx index 88614292..7aaec6d7 100644 --- a/tests/control.test.tsx +++ b/tests/control.test.tsx @@ -40,4 +40,18 @@ describe('Form.Control', () => { await changeValue(getInput(container), ['bamboo', '']); matchError(container, "'test' is required"); }); + + it('value no change', async () => { + const fn = jest.fn(); + const { container } = render( +
+ value?.replace(/\D/g, '') || undefined} /> + , + ); + + await changeValue(getInput(container), 'bamboo'); + expect(fn).toHaveBeenCalledTimes(0); + await changeValue(getInput(container), '1'); + expect(fn).toHaveBeenCalledTimes(1); + }); });