From f7b1341b30855ec9b11762035af2845f3e4699d6 Mon Sep 17 00:00:00 2001 From: Pelps12 Date: Thu, 18 Apr 2024 15:02:16 -0500 Subject: [PATCH 1/2] Change "Enter" submit logic --- apps/web/src/components/Main.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/Main.tsx b/apps/web/src/components/Main.tsx index b088b9f9..64650efd 100644 --- a/apps/web/src/components/Main.tsx +++ b/apps/web/src/components/Main.tsx @@ -388,7 +388,7 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { autoFocus: true, onChange: (e) => setValue(e.target.value), onKeyDown: (e) => { - if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { + if (e.key === "Enter" && !e.shiftKey) { onSend(); } }, @@ -507,7 +507,7 @@ export function Chat({ autoFocus: true, onChange: onValueChange, onKeyDown: (e) => { - if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { + if (e.key === "Enter" && !e.shiftKey) { askQuestion(); } }, From 5f6892405e349e7cbf0bf987d62ba1bd20498c6a Mon Sep 17 00:00:00 2001 From: Pelps12 Date: Fri, 19 Apr 2024 00:49:32 -0500 Subject: [PATCH 2/2] Fix default behavior bug --- apps/web/src/components/Main.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/Main.tsx b/apps/web/src/components/Main.tsx index 64650efd..8ac52569 100644 --- a/apps/web/src/components/Main.tsx +++ b/apps/web/src/components/Main.tsx @@ -344,7 +344,8 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { autoFocus: true, onChange: onValueChange, onKeyDown: (e) => { - if (e.key === "Enter") { + if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault(); onSend(); } }, @@ -389,6 +390,7 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { onChange: (e) => setValue(e.target.value), onKeyDown: (e) => { if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault(); onSend(); } }, @@ -508,6 +510,7 @@ export function Chat({ onChange: onValueChange, onKeyDown: (e) => { if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault(); askQuestion(); } },