Skip to content

Commit f4a9fe2

Browse files
anduimaguinexxeln
andauthored
fix(app): ignore repeated Enter submits in prompt input (#18148)
Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com>
1 parent 5a0bfa7 commit f4a9fe2

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

packages/app/src/components/prompt-input.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,20 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
12411241

12421242
// Note: Shift+Enter is handled earlier, before IME check
12431243
if (event.key === "Enter" && !event.shiftKey) {
1244+
event.preventDefault()
1245+
if (event.repeat) return
1246+
if (
1247+
working() &&
1248+
prompt
1249+
.current()
1250+
.map((part) => ("content" in part ? part.content : ""))
1251+
.join("")
1252+
.trim().length === 0 &&
1253+
imageAttachments().length === 0 &&
1254+
commentCount() === 0
1255+
) {
1256+
return
1257+
}
12441258
handleSubmit(event)
12451259
}
12461260
}

0 commit comments

Comments
 (0)