Skip to content

An AI-powered search engine with a generative UI

fix: Fix scroll listener registration to properly detect bottom position

Yoshiki Miura50b0fca6d31e
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx
index 8ed75805..87a7d948 100644
--- a/components/chat-panel.tsx
+++ b/components/chat-panel.tsx
@@ -41,8 +41,6 @@ interface ChatPanelProps {
scrollContainerRef: React.RefObject<HTMLDivElement>
uploadedFiles: UploadedFile[]
setUploadedFiles: React.Dispatch<React.SetStateAction<UploadedFile[]>>
- /** Function to set whether the scroll is at the bottom */
- setIsAtBottom: React.Dispatch<React.SetStateAction<boolean>>
}
export function ChatPanel({
@@ -59,8 +57,7 @@ export function ChatPanel({
showScrollToBottomButton,
uploadedFiles,
setUploadedFiles,
- scrollContainerRef,
- setIsAtBottom
+ scrollContainerRef
}: ChatPanelProps) {
const router = useRouter()
const inputRef = useRef<HTMLTextAreaElement>(null)
@@ -134,8 +131,6 @@ export function ChatPanel({
top: scrollContainer.scrollHeight,
behavior: 'smooth'
})
- // Immediately hide the button when clicked
- setIsAtBottom(true)
}
}
diff --git a/components/chat.tsx b/components/chat.tsx
index 1e14d63d..e7806039 100644
--- a/components/chat.tsx
+++ b/components/chat.tsx
@@ -231,7 +231,7 @@ export function Chat({
handleScroll() // Set initial state
return () => container.removeEventListener('scroll', handleScroll)
- }, [])
+ }, [messages.length])
// Check scroll position when messages change (during generation)
useEffect(() => {
@@ -451,7 +451,6 @@ export function Chat({
uploadedFiles={uploadedFiles}
setUploadedFiles={setUploadedFiles}
scrollContainerRef={scrollContainerRef}
- setIsAtBottom={setIsAtBottom}
/>
<DragOverlay visible={isDragging} />
<AuthModal open={showAuthModal} onOpenChange={setShowAuthModal} />