Skip to content

Commit

Permalink
Merge pull request #404 from cyhhao/pr2
Browse files Browse the repository at this point in the history
optimize: scrolling experience
  • Loading branch information
Yidadaa authored Apr 3, 2023
2 parents b5a69b6 + ae8ceb8 commit d923869
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,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 @@ -527,7 +528,11 @@ export function Chat(props: {
className={styles["chat-body"]}
ref={scrollRef}
onScroll={(e) => onChatBodyScroll(e.currentTarget)}
onTouchStart={() => inputRef.current?.blur()}
onWheel={() => setAutoScroll(false)}
onTouchStart={() => {
inputRef.current?.blur();
setAutoScroll(false);
}}
>
{messages.map((message, i) => {
const isUser = message.role === "user";
Expand Down Expand Up @@ -588,7 +593,6 @@ export function Chat(props: {
if (!isMobileScreen()) return;
setUserInput(message.content);
}}
onMouseOver={() => inputRef.current?.blur()}
>
<Markdown content={message.content} />
</div>
Expand Down Expand Up @@ -623,9 +627,6 @@ export function Chat(props: {
setAutoScroll(false);
setTimeout(() => setPromptHints([]), 500);
}}
onMouseOver={() => {
inputRef.current?.focus();
}}
autoFocus={!props?.sideBarShowing}
/>
<IconButton
Expand Down

1 comment on commit d923869

@vercel
Copy link

@vercel vercel bot commented on d923869 Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.