Skip to content

Fix submit error trigger#25

Merged
elvisdragonmao merged 1 commit intomainfrom
fix/fix-submit-error-trigger
Feb 24, 2026
Merged

Fix submit error trigger#25
elvisdragonmao merged 1 commit intomainfrom
fix/fix-submit-error-trigger

Conversation

@Kyle9410-Chen
Copy link
Member

Type of changes

  • Fix

Purpose

  • Fix submit error trigger.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts how the form submission is triggered on FormDetailPage to avoid unintended submit behavior and ensure the submit logic runs only when explicitly invoked.

Changes:

  • Removed the <form onSubmit={handleSubmit}> handler.
  • Changed the final “送出” button from type="submit" to type="button" and wired it to onClick={handleSubmit}.
Comments suppressed due to low confidence (2)

src/features/form/components/FormDetailPage.tsx:1005

  • <form> no longer has an onSubmit handler. This can regress keyboard behavior (Enter-to-submit) and can also allow the browser’s default form submission in some cases (page navigation/reload) since the wrapper is still a real form element. Consider either (a) restoring onSubmit to always preventDefault() and only call the submit logic when isLastStep (so Enter doesn’t trigger validation/errors on earlier steps), or (b) replacing the <form> with a non-form container if you don’t want native form semantics at all.
				<form className={styles.form}>
					{sections[currentStep] && (

src/features/form/components/FormDetailPage.tsx:1032

  • handleSubmit is typed as (e: React.FormEvent) => ... and calls e.preventDefault(), but it’s now wired to a button onClick, which provides a mouse event (or potentially no event depending on how Button is used). Refactor the submit routine to not depend on a FormEvent (e.g., make it parameterless and remove preventDefault), and if you keep form submission support, add a small onSubmit wrapper that passes the event and calls the shared submit routine.
							<Button type="button" onClick={handleSubmit} disabled={responseProgress === "SUBMITTED"} processing={submitResponseMutation.isPending} themeColor={primaryThemeColor}>
								{responseProgress === "SUBMITTED" ? "已儲存編輯" : "送出"}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@elvisdragonmao elvisdragonmao merged commit 70cc4a2 into main Feb 24, 2026
9 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.

3 participants