From 2dd0393bedb7c58a8bc01c7a32eeea5c86b56f5d Mon Sep 17 00:00:00 2001
From: galiprandi <20272796+galiprandi@users.noreply.github.com>
Date: Tue, 16 Jun 2026 04:43:49 +0000
Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Quality:=20Bug=20Fix=20-=20Fix?=
=?UTF-8?q?=20Form=20onSubmit=20prop=20overwriting=20internal=20handler?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This change fixes a bug where providing an `onSubmit` prop to the `Form` component would prevent `onSubmitValues` from being called.
It also improves component metadata by adding `displayName` and corrects JSDoc for `FormProps`.
Changes:
- Destructure `onSubmit` as `onSubmitProp` in `FormInner` to avoid it being overwritten by the `restProps` spread.
- Manually call `onSubmitProp` within the internal `onSubmit` handler.
- Ensure `restProps` are spread before `onSubmit` on the native `
,
+ )
+
+ fireEvent.submit(screen.getByTestId(testId))
+
+ expect(onSubmitValues).toHaveBeenCalledWith({
+ name: 'John',
+ })
+ expect(onSubmit).toHaveBeenCalled()
+ })
})
diff --git a/lib/components/Form/index.tsx b/lib/components/Form/index.tsx
index 68ad873..04bbd21 100644
--- a/lib/components/Form/index.tsx
+++ b/lib/components/Form/index.tsx
@@ -5,7 +5,12 @@ const FormInner = (
props: FormProps,
ref: ForwardedRef,
): JSX.Element => {
- const { onSubmitValues, filterEmptyValues, ...restProps } = props
+ const {
+ onSubmitValues,
+ filterEmptyValues,
+ onSubmit: onSubmitProp,
+ ...restProps
+ } = props
/**
* Handles the form submission event.
@@ -31,9 +36,9 @@ const FormInner = (
onSubmitValues(values)
}
- props.onSubmit && props.onSubmit(event)
+ onSubmitProp && onSubmitProp(event)
}
- return
+ return
}
/**
@@ -73,6 +78,8 @@ export const Form = forwardRef(FormInner) as (
props: FormProps & React.RefAttributes,
) => JSX.Element
+Form.displayName = 'Form'
+
/**
* The properties for the Form component.
*
@@ -99,8 +106,6 @@ export interface FormProps
onSubmitValues?: (values: T) => void
/**
* A flag to determine if empty values should be included in the form values.
- *
- * @param {boolean} filterEmptyValues - A flag to determine if empty values should be included in the form values.
*/
filterEmptyValues?: boolean
}
From 3c84bce7b595363dcb13fd1f57840ea26d6ab0c2 Mon Sep 17 00:00:00 2001
From: galiprandi <20272796+galiprandi@users.noreply.github.com>
Date: Tue, 16 Jun 2026 04:49:22 +0000
Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20Quality:=20Bug=20Fix=20-=20Fix?=
=?UTF-8?q?=20Form=20onSubmit=20prop=20and=20TypeScript=20type=20definitio?=
=?UTF-8?q?n?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This change fixes a bug where providing an `onSubmit` prop to the `Form` component would prevent `onSubmitValues` from being called.
It also fixes a TypeScript error when setting `displayName` on a generic `forwardRef` component.
Changes:
- Destructure `onSubmit` as `onSubmitProp` in `FormInner` to avoid it being overwritten by the `restProps` spread.
- Manually call `onSubmitProp` within the internal `onSubmit` handler.
- Ensure `restProps` are spread before `onSubmit` on the native `
* ```
*/
-export const Form = forwardRef(FormInner) as (
- props: FormProps & React.RefAttributes,
-) => JSX.Element
+export const Form = forwardRef(FormInner) as {
+ (props: FormProps & React.RefAttributes): JSX.Element
+ displayName?: string
+}
Form.displayName = 'Form'