Merged
Conversation
elvisdragonmao
approved these changes
Feb 24, 2026
Contributor
There was a problem hiding this comment.
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"totype="button"and wired it toonClick={handleSubmit}.
Comments suppressed due to low confidence (2)
src/features/form/components/FormDetailPage.tsx:1005
<form>no longer has anonSubmithandler. 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) restoringonSubmitto alwayspreventDefault()and only call the submit logic whenisLastStep(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
handleSubmitis typed as(e: React.FormEvent) => ...and callse.preventDefault(), but it’s now wired to a buttononClick, which provides a mouse event (or potentially no event depending on howButtonis used). Refactor the submit routine to not depend on aFormEvent(e.g., make it parameterless and removepreventDefault), and if you keep form submission support, add a smallonSubmitwrapper 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of changes
Purpose