From ae57db274ee1dfffce392b676a152cb48112427f Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Fri, 21 Feb 2025 14:14:15 +0100 Subject: [PATCH] fix(MessagesList): check if chats are non-scrollable Signed-off-by: Maksim Sukharev --- src/components/MessagesList/MessagesList.vue | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/MessagesList/MessagesList.vue b/src/components/MessagesList/MessagesList.vue index b7c2aa69549..bd13b7eb500 100644 --- a/src/components/MessagesList/MessagesList.vue +++ b/src/components/MessagesList/MessagesList.vue @@ -300,6 +300,10 @@ export default { // scroll to bottom if needed this.scrollToBottom({ smooth: false }) + this.$nextTick(() => { + this.checkChatNotScrollable() + }) + if (this.conversation?.type === CONVERSATION.TYPE.NOTE_TO_SELF) { this.$nextTick(() => { this.updateTasksCount() @@ -320,8 +324,7 @@ export default { this.$nextTick(() => { this.checkSticky() // setting wheel event for non-scrollable chat - const isScrollable = this.$refs.scroller.scrollHeight > this.$refs.scroller.clientHeight - if (!this.isChatBeginningReached && !isScrollable) { + if (!this.isChatBeginningReached && this.checkChatNotScrollable()) { this.$refs.scroller.addEventListener('wheel', this.handleWheelEvent, { passive: true }) } }) @@ -385,6 +388,8 @@ export default { this.$refs.scroller.scrollTo({ top: this.$refs.scroller.scrollHeight, }) + } else { + this.checkChatNotScrollable() } }, @@ -1188,10 +1193,7 @@ export default { this.$refs.scroller.scrollTop += this.$refs.scroller.offsetHeight / 4 } - if (this.$refs.scroller && this.$refs.scroller.clientHeight === this.$refs.scroller.scrollHeight) { - // chat is not scrollable - this.setChatScrolledToBottom(true) - } + this.checkChatNotScrollable() if (highlightAnimation && scrollElement === element) { // element is visible, highlight it @@ -1315,6 +1317,18 @@ export default { this.chatExtrasStore.setTasksCounters({ tasksCount, tasksDoneCount }) }, + checkChatNotScrollable() { + const isNotScrollable = this.$refs.scroller + ? this.$refs.scroller.clientHeight === this.$refs.scroller.scrollHeight + : false + + if (isNotScrollable && !this.isChatScrolledToBottom) { + this.setChatScrolledToBottom(true) + } + + return isNotScrollable + }, + handleWheelEvent(event) { // If messages fit in the viewport and user scrolls up, we need to trigger the loading of older messages if (event.deltaY < 0) {