Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from athrael-soju/30-fix-vertical-scroll-not-w…
Browse files Browse the repository at this point in the history
…orking-in-chat

Resolve issue with hook
  • Loading branch information
athrael-soju committed Oct 9, 2023
2 parents 2a292c2 + d017250 commit ec4c197
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/components/Chat/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export default function Messages({
const sentences = useRef<string[]>([]);
const speechIndex = useRef<number>(0);

// Scroll to the most recent message whenever a new message is added
useEffect(() => {
if (messagesEndRef.current) {
messagesEndRef.current.scrollIntoView({ behavior: 'smooth' });
}
}, [messages]);

// Web Speech API Hooks
useEffect(() => {
if (isWebSpeechEnabled) {
Expand Down

0 comments on commit ec4c197

Please sign in to comment.