Skip to content
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

Fix: limit chat scrolling to chat transcript container. (PT-188491995) #19

Merged
merged 1 commit into from
Dec 19, 2024
Merged
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
3 changes: 1 addition & 2 deletions src/components/chat-transcript-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ export const ChatTranscriptMessage = ({message, showDebugLog}: IProps) => {
data-testid="chat-message"
role="listitem"
>
<h3 aria-label="speaker" data-testid="chat-message-speaker">
<h3 data-testid="chat-message-speaker">
{speaker}
</h3>
<div
aria-label="message"
className={`chat-message-content ${speakerClass}`}
data-testid="chat-message-content"
>
Expand Down
1 change: 0 additions & 1 deletion src/components/chat-transcript.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe("test chat transcript component", () => {
expect(speaker).toHaveTextContent(chatTranscript.messages[index].speaker);

const content = within(message).getByTestId("chat-message-content");
expect(content).toHaveAttribute("aria-label", "message");
expect(content).toHaveTextContent(chatTranscript.messages[index].messageContent.content);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/chat-transcript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export const ChatTranscriptComponent = observer(({chatTranscript, showDebugLog,
const chatTranscriptContainer = chatTranscriptRef.current;
if (chatTranscriptContainer) {
const lastMessage = chatTranscriptContainer.querySelector(".chat-transcript__message:last-of-type");
lastMessage?.scrollIntoView({behavior: "smooth"});
lastMessage?.scrollIntoView({behavior: "smooth", block: "nearest"});
}
}, [chatTranscript.messages.length]);
}, [chatTranscript.messages.length, isLoading]);

return (
<div ref={chatTranscriptRef} id="chat-transcript" className="chat-transcript" data-testid="chat-transcript" role="group">
Expand Down
7 changes: 3 additions & 4 deletions src/components/loading-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import { timeStamp } from "../utils/utils";

export const LoadingMessage = () => {
return (
<section
<div
aria-label={`${DAVAI_SPEAKER} at ${timeStamp()}`}
className={`chat-transcript__message ${DAVAI_SPEAKER.toLowerCase()}`}
data-testid="chat-message"
role="listitem"
>
<h3 aria-label="speaker" data-testid="chat-message-speaker">
<h3 data-testid="chat-message-speaker">
{DAVAI_SPEAKER}
</h3>
<div
aria-label="message"
className={`chat-message-content ${DAVAI_SPEAKER.toLowerCase()}`}
data-testid="chat-message-content"
>
Expand All @@ -25,6 +24,6 @@ export const LoadingMessage = () => {
>
</div>
</div>
</section>
</div>
);
};
Loading