Suyious / purrr.frontend

Frontend for Purrr - Chat Application that connects randomly among online users
https://purrr.chat
1 stars 2 forks source link

Bug: No scroll on new message when message has attachment or long message #28

Closed Suyious closed 1 month ago

Suyious commented 1 month ago

When you send a new message and you are already scrolled to the bottom of the screen, the new message is supposed to appear with the chat being scrolled up to bring it to view. This functionality works when the message is just a small text message. However, when the new message takes a large amount of space ( like in case of attachments or long string of next ), the automatic scroll fails. This is mostly because of the way we are detecting if the chat is scrolled to the bottom. Currently we use:

function isScrolledToBottom() {
    const rect = chatBottom.current?.getBoundingClientRect();
    return (rect && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight));
}

This might not be the best way for implementing the usecase and we need a better solution.