From 624ebf13d2491db7e93e324b329b9e51925643e3 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Tue, 16 Apr 2024 09:55:27 +0200 Subject: [PATCH] fix(MessagesList): small fixes for focus a message from URL Signed-off-by: DorraJaouad --- src/components/MessagesList/MessagesList.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/MessagesList/MessagesList.vue b/src/components/MessagesList/MessagesList.vue index 2620053373d..48ee5274fb2 100644 --- a/src/components/MessagesList/MessagesList.vue +++ b/src/components/MessagesList/MessagesList.vue @@ -301,8 +301,11 @@ export default { this.softUpdateByDateGroups(this.messagesGroupedByDateByAuthor, newGroups) } - // scroll to bottom if needed - this.scrollToBottom({ smooth: true }) + // Scroll only if there is no focused messages + const focusedMessage = this.getMessageIdFromHash() + if (!focusedMessage) { + this.scrollToBottom({smooth: true}) + } }, }, }, @@ -1065,7 +1068,7 @@ export default { */ scrollToBottom(options = {}) { this.$nextTick(() => { - if (!this.$refs.scroller) { + if (!this.$refs.scroller || this.isFocusingMessage) { return } @@ -1088,7 +1091,6 @@ export default { newTop = this.$refs.scroller.scrollHeight this.setChatScrolledToBottom(true) } - this.$refs.scroller.scrollTo({ top: newTop, behavior: options?.smooth ? 'smooth' : 'auto', @@ -1127,7 +1129,7 @@ export default { } if (highlightAnimation) { - EventBus.$emit('highlight-message', messageId) + EventBus.emit('highlight-message', messageId) } this.isFocusingMessage = false