From 4a34ccde05c1b24202d14e7242aebaf84fe3ad8a Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 29 Aug 2021 16:58:37 -0700 Subject: [PATCH] Increase do not autoscroll buffer to fix chat not scrolling to bottom. Fixes #1324 --- webroot/js/components/chat/chat.js | 3 ++- webroot/js/utils/constants.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/webroot/js/components/chat/chat.js b/webroot/js/components/chat/chat.js index c249a69e6..7aad405a1 100644 --- a/webroot/js/components/chat/chat.js +++ b/webroot/js/components/chat/chat.js @@ -8,7 +8,6 @@ import { CALLBACKS, SOCKET_MESSAGE_TYPES } from '../../utils/websocket.js'; import { jumpToBottom, debounce, - setLocalStorage, } from '../../utils/helpers.js'; import { extraUserNamesFromMessageHistory } from '../../utils/chat.js'; import { @@ -295,6 +294,7 @@ export default class Chat extends Component { const shouldScroll = scrollHeight >= clientHeight && fullyScrolled - scrollTop < MESSAGE_JUMPTOBOTTOM_BUFFER; + return shouldScroll; } @@ -315,6 +315,7 @@ export default class Chat extends Component { // if the messages list grows in number of child message nodes due to new messages received, scroll to bottom. messageListCallback(mutations) { const numMutations = mutations.length; + if (numMutations) { const item = mutations[numMutations - 1]; if (item.type === 'childList' && item.addedNodes.length) { diff --git a/webroot/js/utils/constants.js b/webroot/js/utils/constants.js index d209e2ce1..febb017a6 100644 --- a/webroot/js/utils/constants.js +++ b/webroot/js/utils/constants.js @@ -52,7 +52,7 @@ export const CHAT_OK_KEYCODES = [ 'Backspace', ]; export const CHAT_KEY_MODIFIERS = ['Control', 'Shift', 'Meta', 'Alt']; -export const MESSAGE_JUMPTOBOTTOM_BUFFER = 300; +export const MESSAGE_JUMPTOBOTTOM_BUFFER = 500; // app styling export const WIDTH_SINGLE_COL = 730;