Skip to content

Commit

Permalink
fix: form::onReset should reset form's "internal" initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobJingleheimer committed Feb 19, 2024
1 parent 9580f9b commit 98067ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/react/Form/Form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/react/Form/Form.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('<Form>', () => {
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', () => {
Expand Down

0 comments on commit 98067ce

Please sign in to comment.