Browse Source

optimize: scrolling experience

cyhhao 2 years ago
parent
commit
a6890c0f58
1 changed files with 7 additions and 3 deletions
  1. 7 3
      app/components/chat.tsx

+ 7 - 3
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";