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.
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:
This might not be the best way for implementing the usecase and we need a better solution.