Conversation
- Add type='button' to FileUploadButton to prevent unwanted form submission - Fixes issue where clicking image upload button would submit form when text was entered - Follows existing pattern used by other buttons in the codebase Fixes #586 Co-Authored-By: Yoshiki Miura <miurap400@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
miurla
approved these changes
Jul 28, 2025
byte-rose
pushed a commit
to Bastsec/morphic
that referenced
this pull request
Sep 23, 2025
…upload-form-submission fix: prevent image upload button from triggering form submission
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.
fix: prevent image upload button from triggering form submission
Summary
Fixed issue #586 where clicking the image upload button (paperclip icon) would trigger form submission when text was already entered in the chat input field. The fix adds
type="button"to the Button component inFileUploadButtonto prevent it from defaulting to submit behavior when clicked inside a form.Root Cause: HTML buttons inside forms default to
type="submit"when no type is specified. The FileUploadButton component is rendered inside the chat form, so clicking it was triggering form submission instead of just opening the file dialog.Solution: Added
type="button"attribute to the Button component, following the same pattern used by other non-submit buttons in the codebase (like the "New Chat" button and "Scroll to Bottom" button).Review & Testing Checklist for Human
type="button"is the correct approach and aligns with how other buttons in the chat panel are implemented.Diagram
%%{ init : { "theme" : "default" }}%% graph TD ChatPanel["components/chat-panel.tsx<br/>Contains form with handleSubmit"]:::context FileUploadButton["components/file-upload-button.tsx<br/>Image upload button component"]:::major-edit Button["Button component<br/>Added type='button'"]:::major-edit Form["HTML form element<br/>onSubmit handler"]:::context Issue["Issue #586<br/>Button triggers form submission"]:::context ChatPanel --> FileUploadButton FileUploadButton --> Button ChatPanel --> Form Form --> Issue Button --> Issue subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
type="button"(see chat-panel.tsx lines 160, 222)Link to Devin run: https://app.devin.ai/sessions/2647080437fa4fc4a47e8b78d49f0b8b
Requested by: @miurla (Yoshiki Miura)