Skip to content

✨ Quality: Bug Fix - Fix Form onSubmit prop overwriting internal handler - #93

Merged
galiprandi merged 2 commits into
mainfrom
quality-form-bug-fix-1311651963730779525
Jun 16, 2026
Merged

✨ Quality: Bug Fix - Fix Form onSubmit prop overwriting internal handler#93
galiprandi merged 2 commits into
mainfrom
quality-form-bug-fix-1311651963730779525

Conversation

@galiprandi

Copy link
Copy Markdown
Owner

This PR addresses a micro quality improvement by fixing a bug in the Form component and improving its documentation and maintainability.

💡 What:

  • Fixed a bug where the onSubmit prop was overwriting the internal submit handler due to the order of props in the spread.
  • Added Form.displayName for better debugging.
  • Cleaned up JSDoc for FormProps.
  • Added a unit test covering the fix.

🎯 Why:

  • The Form component should reliably trigger onSubmitValues even if a custom onSubmit handler is provided for native event access.
  • Correct JSDoc and displayName improve developer experience and maintainability.

📊 Impact:

  • Increased robustness of the Form component.
  • Better documentation.
  • Improved test coverage for edge cases.

✅ Verification:

  • Ran pnpm vitest lib/components/Form/index.test.tsx (all tests passed).
  • Verified with a reproduction test case.
  • Ran pnpm eslint lib/components/Form/index.tsx (no errors).

PR created automatically by Jules for task 1311651963730779525 started by @galiprandi

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.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

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.
@galiprandi
galiprandi merged commit f9ef17d into main Jun 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant