Skip to content

Commit

Permalink
fix(ui): scroll to bottom when a request is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed May 23, 2024
1 parent 62498be commit bf681ae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ee/tabby-ui/components/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,23 @@ function ChatRenderer(
})
}, [answer, isLoading])

React.useLayoutEffect(() => {
// scroll to bottom when a request is sent
if (isLoading) {
if (container) {
container.scrollTo({
top: container.scrollHeight,
behavior: 'smooth'
})
} else {
window.scrollTo({
top: document.body.offsetHeight,
behavior: 'smooth'
})
}
}
}, [isLoading])

React.useEffect(() => {
if (error && qaPairs?.length) {
setQaPairs(prev => {
Expand Down

0 comments on commit bf681ae

Please sign in to comment.