✨ Quality: Bug Fix - Fix Form onSubmit prop overwriting internal handler - #93
Conversation
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 `<form>` element. - Add `Form.displayName = 'Form'`. - Correct JSDoc for `filterEmptyValues` in `FormProps`. - Add unit test to verify that both `onSubmitValues` and `onSubmit` are called when provided.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…ition 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 `<form>` element. - Add `Form.displayName = 'Form'` and update its type cast to include `displayName`. - Correct JSDoc for `filterEmptyValues` in `FormProps`. - Add unit test to verify that both `onSubmitValues` and `onSubmit` are called when provided.
This PR addresses a micro quality improvement by fixing a bug in the
Formcomponent and improving its documentation and maintainability.💡 What:
onSubmitprop was overwriting the internal submit handler due to the order of props in the spread.Form.displayNamefor better debugging.FormProps.🎯 Why:
Formcomponent should reliably triggeronSubmitValueseven if a customonSubmithandler is provided for native event access.displayNameimprove developer experience and maintainability.📊 Impact:
Formcomponent.✅ Verification:
pnpm vitest lib/components/Form/index.test.tsx(all tests passed).pnpm eslint lib/components/Form/index.tsx(no errors).PR created automatically by Jules for task 1311651963730779525 started by @galiprandi