Skip to content

Commit

Permalink
fix(MessagesList): fix jumping and inconsistent scrolling of chat bec…
Browse files Browse the repository at this point in the history
…ause of widget and references loading

Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Apr 15, 2024
1 parent 3cb73e0 commit 0c0a82c
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,28 @@
<ul v-if="displayMessagesLoader" class="scroller__loading icon-loading" />
</TransitionWrapper>

<ul v-for="(list, dateTimestamp) in messagesGroupedByDateByAuthor"
:key="`section_${dateTimestamp}`"
:ref="`dateGroup-${token}`"
:data-date-timestamp="dateTimestamp"
:class="{'has-sticky': dateTimestamp === stickyDate}">
<li class="messages-group__date">
<span class="messages-group__date-text" role="heading" aria-level="3">
{{ dateSeparatorLabels[dateTimestamp] }}
</span>
</li>
<component :is="messagesGroupComponent(group)"
v-for="group in list"
:key="group.id"
class="messages-group"
:token="token"
:messages="group.messages"
:previous-message-id="group.previousMessageId"
:next-message-id="group.nextMessageId" />
</ul>
<div class="messages-list-wrapper__reversed">
<ul v-for="[dateTimestamp, list] in Object.entries(messagesGroupedByDateByAuthor).reverse()"
:key="`section_${dateTimestamp}`"
:ref="`dateGroup-${token}`"
:data-date-timestamp="dateTimestamp"
:class="{'has-sticky': dateTimestamp === stickyDate}">
<li class="messages-group__date">
<span class="messages-group__date-text" role="heading" aria-level="3">
{{ dateSeparatorLabels[dateTimestamp] }}
</span>
</li>
<component :is="messagesGroupComponent(group)"
v-for="group in list"
:key="group.id"
ref="messagesGroup"
class="messages-group"
:token="token"
:messages="group.messages"
:previous-message-id="group.previousMessageId"
:next-message-id="group.nextMessageId" />
</ul>
</div>

<template v-if="showLoadingAnimation">
<LoadingPlaceholder type="messages"
Expand All @@ -78,7 +81,6 @@ import uniqueId from 'lodash/uniqueId.js'
import Message from 'vue-material-design-icons/Message.vue'

import Axios from '@nextcloud/axios'
import { getCapabilities } from '@nextcloud/capabilities'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import moment from '@nextcloud/moment'

Expand Down Expand Up @@ -1255,6 +1257,11 @@ export default {
}
}

.messages-list-wrapper__reversed {
display: flex;
flex-direction: column-reverse;
}

.messages-group {
&__date {
position: sticky;
Expand Down

0 comments on commit 0c0a82c

Please sign in to comment.