Skip to content

fix: resolve chat UI scrolling issues with flexbox layout #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 20 additions & 30 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ export default function App() {
});

useEffect(() => {
// チャットエリア内で最下部にスクロール
if (scrollAreaRef.current) {
const scrollViewport = scrollAreaRef.current.querySelector(
"[data-radix-scroll-area-viewport]"
);
if (scrollViewport) {
scrollViewport.scrollTop = scrollViewport.scrollHeight;
}
scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight;
}
}, [thread.messages]);

Expand Down Expand Up @@ -154,30 +150,24 @@ export default function App() {

return (
<div className="flex h-screen bg-neutral-800 text-neutral-100 font-sans antialiased">
<main className="flex-1 flex flex-col overflow-hidden max-w-4xl mx-auto w-full">
<div
className={`flex-1 overflow-y-auto ${
thread.messages.length === 0 ? "flex" : ""
}`}
>
{thread.messages.length === 0 ? (
<WelcomeScreen
handleSubmit={handleSubmit}
isLoading={thread.isLoading}
onCancel={handleCancel}
/>
) : (
<ChatMessagesView
messages={thread.messages}
isLoading={thread.isLoading}
scrollAreaRef={scrollAreaRef}
onSubmit={handleSubmit}
onCancel={handleCancel}
liveActivityEvents={processedEventsTimeline}
historicalActivities={historicalActivities}
/>
)}
</div>
<main className="flex-1 flex flex-col max-w-4xl mx-auto w-full">
{thread.messages.length === 0 ? (
<WelcomeScreen
handleSubmit={handleSubmit}
isLoading={thread.isLoading}
onCancel={handleCancel}
/>
) : (
<ChatMessagesView
messages={thread.messages}
isLoading={thread.isLoading}
scrollAreaRef={scrollAreaRef}
onSubmit={handleSubmit}
onCancel={handleCancel}
liveActivityEvents={processedEventsTimeline}
historicalActivities={historicalActivities}
/>
)}
</main>
</div>
);
Expand Down
19 changes: 10 additions & 9 deletions frontend/src/components/ChatMessagesView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type React from "react";
import type { Message } from "@langchain/langgraph-sdk";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Loader2, Copy, CopyCheck } from "lucide-react";
import { InputForm } from "@/components/InputForm";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -253,7 +252,7 @@ export function ChatMessagesView({

return (
<div className="flex flex-col h-full">
<ScrollArea className="flex-grow" ref={scrollAreaRef}>
<div className="flex-1 overflow-y-auto" ref={scrollAreaRef}>
<div className="p-4 md:p-6 space-y-2 max-w-4xl mx-auto pt-16">
{messages.map((message, index) => {
const isLast = index === messages.length - 1;
Expand Down Expand Up @@ -309,13 +308,15 @@ export function ChatMessagesView({
</div>
)}
</div>
</ScrollArea>
<InputForm
onSubmit={onSubmit}
isLoading={isLoading}
onCancel={onCancel}
hasHistory={messages.length > 0}
/>
</div>
<div className="bg-neutral-800 border-t border-neutral-700">
<InputForm
onSubmit={onSubmit}
isLoading={isLoading}
onCancel={onCancel}
hasHistory={messages.length > 0}
/>
</div>
</div>
);
}