From a6890c0f58c5f9895fdcfa74763f5f205071e43e Mon Sep 17 00:00:00 2001 From: cyhhao Date: Mon, 3 Apr 2023 14:56:13 +0800 Subject: [PATCH 1/3] optimize: scrolling experience --- app/components/chat.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 70afa319..34cef0b6 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -377,7 +377,8 @@ export function Chat(props: { chatStore.onUserInput(userInput).then(() => setIsLoading(false)); setUserInput(""); setPromptHints([]); - inputRef.current?.focus(); + if (!isMobileScreen()) inputRef.current?.focus(); + setAutoScroll(true); }; // stop response @@ -533,8 +534,11 @@ export function Chat(props: { className={styles["chat-body"]} ref={scrollRef} onScroll={(e) => onChatBodyScroll(e.currentTarget)} - onMouseOver={() => inputRef.current?.blur()} - onTouchStart={() => inputRef.current?.blur()} + onWheel={() => setAutoScroll(false)} + onTouchStart={() => { + inputRef.current?.blur(); + setAutoScroll(false); + }} > {messages.map((message, i) => { const isUser = message.role === "user"; From 8db26bbd5ff843ee183f1493a23fdeb66c743a0d Mon Sep 17 00:00:00 2001 From: cyhhao Date: Mon, 3 Apr 2023 15:20:16 +0800 Subject: [PATCH 2/3] rm msg body mouseover --- app/components/chat.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 1499e816..4cc60fa5 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -593,7 +593,6 @@ export function Chat(props: { if (!isMobileScreen()) return; setUserInput(message.content); }} - onMouseOver={() => inputRef.current?.blur()} > From ae8ceb8dca5fad06b3fb27dc8132526981ad3ecf Mon Sep 17 00:00:00 2001 From: cyhhao Date: Mon, 3 Apr 2023 15:21:03 +0800 Subject: [PATCH 3/3] rm input mouseover --- app/components/chat.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 4cc60fa5..2bd80aa8 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -627,9 +627,6 @@ export function Chat(props: { setAutoScroll(false); setTimeout(() => setPromptHints([]), 500); }} - onMouseOver={() => { - inputRef.current?.focus(); - }} autoFocus={!props?.sideBarShowing} />