summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGrigorii K. Shartsev <me@shgk.me>2023-06-16 14:41:57 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-06-16 14:37:54 +0000
commita87939f6f11d9697fa8edaa5cdad025e370f7d1d (patch)
tree8d0ed55db020eaa2bfd9e24813a659a49785efa6 /src
parentd469e78c3e4ab111691e0d5502795cc168f7eaa7 (diff)
fix(LeftSidebar): fix scroll with new created conversations
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Diffstat (limited to 'src')
-rw-r--r--src/components/LeftSidebar/LeftSidebar.vue9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/components/LeftSidebar/LeftSidebar.vue b/src/components/LeftSidebar/LeftSidebar.vue
index 1d5c91fbb..592d4ce88 100644
--- a/src/components/LeftSidebar/LeftSidebar.vue
+++ b/src/components/LeftSidebar/LeftSidebar.vue
@@ -41,7 +41,7 @@
:title="t('spreed', 'Conversations')" />
<Conversation v-for="item of conversationsList"
:key="item.id"
- ref="conversations"
+ :ref="`conversation-${item.token}`"
:item="item" />
<template v-if="!initialisedConversations">
<LoadingPlaceholder type="conversations" />
@@ -548,7 +548,12 @@ export default {
scrollToConversation(token) {
this.$nextTick(() => {
- const conversation = this.$refs.conversations[this.conversationsList.findIndex(item => item.token === token)].$el
+ // In Vue 2 ref on v-for is always an array and its order is not guaranteed to match the order of v-for source
+ // See https://github.com/vuejs/vue/issues/4952#issuecomment-280661367
+ // Fixed in Vue 3
+ // Temp solution - use unique ref name for each v-for element. The value is still array but with one element
+ // TODO: Vue3: remove [0] here or use object for template refs
+ const conversation = this.$refs[`conversation-${token}`]?.[0].$el
if (!conversation) {
return
}