Skip to content

Commit

Permalink
fix(MessagesList): small fixes for focus a message from URL
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Apr 16, 2024
1 parent fa20d12 commit 624ebf1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Check failure on line 307 in src/components/MessagesList/MessagesList.vue

View workflow job for this annotation

GitHub Actions / NPM lint

A space is required after '{'

Check failure on line 307 in src/components/MessagesList/MessagesList.vue

View workflow job for this annotation

GitHub Actions / NPM lint

A space is required before '}'
}
},
},
},
Expand Down Expand Up @@ -1065,7 +1068,7 @@ export default {
*/
scrollToBottom(options = {}) {
this.$nextTick(() => {
if (!this.$refs.scroller) {
if (!this.$refs.scroller || this.isFocusingMessage) {
return
}

Expand All @@ -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',
Expand Down Expand Up @@ -1127,7 +1129,7 @@ export default {
}

if (highlightAnimation) {
EventBus.$emit('highlight-message', messageId)
EventBus.emit('highlight-message', messageId)
}
this.isFocusingMessage = false

Expand Down

0 comments on commit 624ebf1

Please sign in to comment.