fix: prevent attachment button click from triggering form submit#1471
fix: prevent attachment button click from triggering form submit#1471Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
d9f04d2 to
363f806
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 363f806b01
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| onClick={(e: React.MouseEvent) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| attachments.openFileDialog(); |
There was a problem hiding this comment.
Apply submit guard on the rendered attachment trigger
This handler is added to AttachmentButton, but that component is not imported anywhere in web/src (repo-wide rg "AttachmentButton" only finds this definition), so the fix never runs in the chat composer. The attachment control users actually click is in global-config-controls.tsx (<Button onClick={() => attachments.openFileDialog()}> inside PromptInput), so the reported submit-on-click behavior remains unchanged after this commit.
Useful? React with 👍 / 👎.
The Paperclip (attach files) button in GlobalConfigControls is rendered inside the prompt form without an explicit type attribute. Since the default button type in a form is 'submit', clicking it triggers a form submission in addition to opening the file dialog. Add type="button" to prevent the implicit form submit. Fixes MoonshotAI#1428
363f806 to
480fcca
Compare
Problem
Clicking the attachment (paperclip) button in the web UI triggers a form submit, sending the current input text before the file dialog opens.
Fix
Add
event.preventDefault()andevent.stopPropagation()to the attachment button's click handler to ensure only the file dialog is opened.Fixes #1428