Jelajahi Sumber

fix(app): ignore repeated Enter submits in prompt input (#18148)

Co-authored-by: Shoubhit Dash <[email protected]>
Andrew Maguire 4 minggu lalu
induk
melakukan
f4a9fe29a3
1 mengubah file dengan 14 tambahan dan 0 penghapusan
  1. 14 0
      packages/app/src/components/prompt-input.tsx

+ 14 - 0
packages/app/src/components/prompt-input.tsx

@@ -1241,6 +1241,20 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
 
     // Note: Shift+Enter is handled earlier, before IME check
     if (event.key === "Enter" && !event.shiftKey) {
+      event.preventDefault()
+      if (event.repeat) return
+      if (
+        working() &&
+        prompt
+          .current()
+          .map((part) => ("content" in part ? part.content : ""))
+          .join("")
+          .trim().length === 0 &&
+        imageAttachments().length === 0 &&
+        commentCount() === 0
+      ) {
+        return
+      }
       handleSubmit(event)
     }
   }