Skip to content

Commit a4f7048

Browse files
authored
fix(Form): fix missing submit event (#2303)
1 parent 5df7f90 commit a4f7048

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/components/src/integrations/react-hook-form/components/Form/Form.browser.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ describe("submission", () => {
133133
const textField = page.getByPlaceholder("textfield");
134134
await userEvent.type(textField, "hello");
135135
await userEvent.click(submitButton);
136-
expect(onSubmit).toHaveBeenCalledWith({ test: "hello" });
136+
expect(onSubmit).toHaveBeenCalledWith(
137+
{ test: "hello" },
138+
expect.objectContaining({ type: "submit" }),
139+
);
137140
});
138141

139142
test("afterSubmit callback is called after successful submission", async () => {

packages/components/src/integrations/react-hook-form/components/Form/Form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export function Form<F extends FieldValues>(props: FormProps<F>) {
6666
const handleSubmit = (e?: FormEvent | F) => {
6767
const formEvent = e && "nativeEvent" in e ? (e as FormEvent) : undefined;
6868
formEvent?.stopPropagation();
69-
return form.handleSubmit((e) => {
70-
const submitResult = onSubmit(e);
69+
return form.handleSubmit((values, event) => {
70+
const submitResult = onSubmit(values, event);
7171
if (submitResult instanceof Promise) {
7272
return submitResult.then(handleSubmitResult);
7373
}

0 commit comments

Comments
 (0)