Skip to content

An AI-powered search engine with a generative UI

fix: Hide scroll-to-bottom button immediately on click

Yoshiki Miura8eeb2601809e
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx
index 87a7d948..8ed75805 100644
--- a/components/chat-panel.tsx
+++ b/components/chat-panel.tsx
@@ -41,6 +41,8 @@ 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({
@@ -57,7 +59,8 @@ export function ChatPanel({
showScrollToBottomButton,
uploadedFiles,
setUploadedFiles,
- scrollContainerRef
+ scrollContainerRef,
+ setIsAtBottom
}: ChatPanelProps) {
const router = useRouter()
const inputRef = useRef<HTMLTextAreaElement>(null)
@@ -131,6 +134,8 @@ 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 5deb46ae..1e14d63d 100644
--- a/components/chat.tsx
+++ b/components/chat.tsx
@@ -451,6 +451,7 @@ export function Chat({
uploadedFiles={uploadedFiles}
setUploadedFiles={setUploadedFiles}
scrollContainerRef={scrollContainerRef}
+ setIsAtBottom={setIsAtBottom}
/>
<DragOverlay visible={isDragging} />
<AuthModal open={showAuthModal} onOpenChange={setShowAuthModal} />