Skip to content

Commit

Permalink
Merge pull request #9795 from nextcloud/fix/noid/scroll-to-new-create…
Browse files Browse the repository at this point in the history
…d-conversation

fix(LeftSidebar): fix scroll with new created conversations
  • Loading branch information
ShGKme authored Jun 16, 2023
2 parents ba03cd8 + 339a167 commit 711c95f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/LeftSidebar/LeftSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 711c95f

Please sign in to comment.