Skip to content

Commit

Permalink
optimize: scrolling experience
Browse files Browse the repository at this point in the history
  • Loading branch information
cyhhao committed Apr 3, 2023
1 parent 73f4ea3 commit a6890c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit a6890c0

Please sign in to comment.