Skip to content

Commit d9f04d2

Browse files
committed
fix: prevent attachment button click from triggering form submit
Clicking the attachment button in the web UI inadvertently triggers a form submit, sending the current input text before the file dialog opens. Add preventDefault() and stopPropagation() to the click handler to ensure only the file dialog is opened without side effects. Fixes #1428
1 parent 94212ea commit d9f04d2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

web/src/features/chat/components/attachment-button.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ export function AttachmentButton() {
55
const attachments = usePromptInputAttachments();
66

77
return (
8-
<PromptInputButton onClick={() => attachments.openFileDialog()}>
8+
<PromptInputButton
9+
onClick={(e: React.MouseEvent) => {
10+
e.preventDefault();
11+
e.stopPropagation();
12+
attachments.openFileDialog();
13+
}}
14+
>
915
<PaperclipIcon className="size-4" />
1016
</PromptInputButton>
1117
);

0 commit comments

Comments
 (0)