From dd20c36a557b37726ff74635fdef9f7fef535c4c Mon Sep 17 00:00:00 2001 From: xiaotianxt Date: Thu, 6 Apr 2023 20:38:10 +0800 Subject: [PATCH] fix: distinguish PC/Mobile behavior on auto-scroll The chat list should be set to auto-scroll on mobile screen when the input textarea is focused. It should not behave like that on PC screen because user may want to refer to previous content. --- app/components/chat.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 90c88d97b..a8b53fea3 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -421,6 +421,7 @@ export function Chat(props: { // check if should send message const onInputKeyDown = (e: React.KeyboardEvent) => { if (shouldSubmit(e)) { + setAutoScroll(true); onUserSubmit(); e.preventDefault(); } @@ -667,7 +668,7 @@ export function Chat(props: { onInput={(e) => onInput(e.currentTarget.value)} value={userInput} onKeyDown={onInputKeyDown} - onFocus={() => setAutoScroll(true)} + onFocus={() => setAutoScroll(isMobileScreen())} onBlur={() => { setAutoScroll(false); setTimeout(() => setPromptHints([]), 500);