From 98067ceac0f9c58808e9b60dded02bc43c04a057 Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:44:16 +0100 Subject: [PATCH] fix: `form::onReset` should reset form's "internal" initial state --- lib/react/Form/Form.jsx | 2 +- lib/react/Form/Form.test.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/react/Form/Form.jsx b/lib/react/Form/Form.jsx index 68f202e..f39ebe4 100755 --- a/lib/react/Form/Form.jsx +++ b/lib/react/Form/Form.jsx @@ -79,7 +79,7 @@ export function Form({ onReset={(e) => { props.onReset?.(e); // After everything has succeeded - setup(e.currentTarget, initValues); + initValues.current = { __proto__: null }; is.onSubmit(e); }} onSubmit={(e) => { diff --git a/lib/react/Form/Form.test.jsx b/lib/react/Form/Form.test.jsx index 86ef770..0aba484 100644 --- a/lib/react/Form/Form.test.jsx +++ b/lib/react/Form/Form.test.jsx @@ -140,7 +140,7 @@ describe('
', () => { fireEvent.change(field, { target: { value: sameSearchValue } }); fireEvent.submit(form, { elements: [field] }); expect(onResetCalled, 'reset count (after subsequent submit)').to.equal(1); - expect(onSubmitCalled, 'submit count').to.equal(1); + expect(onSubmitCalled, 'submit count').to.equal(2); }); it('should reset pristine & touched and call handler', () => {