Skip to content

Commit

Permalink
Merge pull request #1644 from solliancenet/sc-fix-chat-thread-scroll-…
Browse files Browse the repository at this point in the history
…behavior-081

(0.8.1) Fix chat thread scroll behavior with accessibility
  • Loading branch information
ciprianjichici authored Aug 28, 2024
2 parents dce4b8c + 4353b13 commit 87930f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
34 changes: 13 additions & 21 deletions src/ui/UserPortal/components/ChatThread.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
<template v-else>
<!-- Messages -->
<template v-if="messages.length !== 0">
<div class="spacer" />
<ChatMessage
v-for="(message, index) in messages.slice()"
v-for="(message, index) in messages.slice().reverse()"
:id="`message-${getMessageOrderFromReversedIndex(index)}`"
:key="`${message.id}-${componentKey}`"
:message="message"
:show-word-animation="
index === messages.length - 1 && userSentMessage && message.sender === 'Assistant'
"
:show-word-animation="index === 0 && userSentMessage && message.sender === 'Assistant'"
role="log"
:tabindex="getMessageOrderFromReversedIndex(index)"
:aria-flowto="
index === 0 ? null : `message-${getMessageOrderFromReversedIndex(index) + 1}`
"
@rate="handleRateMessage($event.message, $event.isLiked)"
/>
</template>
Expand Down Expand Up @@ -99,14 +101,13 @@ export default {
mounted() {
eventBus.on('operation-completed', this.handleOperationCompleted);
this.scrollToBottom();
},
updated() {
this.scrollToBottom();
},
methods: {
getMessageOrderFromReversedIndex(index) {
return this.messages.length - 1 - index;
},
async handleRateMessage(message: Message, isLiked: Message['rating']) {
await this.$appStore.rateMessage(message, isLiked);
},
Expand Down Expand Up @@ -168,12 +169,6 @@ export default {
await this.$appStore.getMessages();
}
},
scrollToBottom() {
this.$nextTick(() => {
this.$refs.messageContainer.scrollTop = this.$refs.messageContainer.scrollHeight;
});
},
},
};
</script>
Expand Down Expand Up @@ -205,7 +200,7 @@ export default {
.chat-thread__messages {
display: flex;
flex-direction: column;
flex-direction: column-reverse;
flex: 1;
overflow-y: auto;
overscroll-behavior: auto;
Expand All @@ -222,6 +217,7 @@ export default {
.empty {
flex-direction: column;
}
.new-chat-alert {
background-color: #fafafa;
margin: 10px;
Expand Down Expand Up @@ -258,8 +254,4 @@ footer {
font-size: 0.85rem;
padding-right: 24px;
}
.spacer {
flex-grow: 1;
}
</style>
4 changes: 2 additions & 2 deletions src/ui/UserPortal/components/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="navbar__content__left__item">
<template v-if="currentSession">
<span>{{ currentSession.name }}</span>
<VTooltip :auto-hide="false" :popper-triggers="['hover']">
<!-- <VTooltip :auto-hide="false" :popper-triggers="['hover']">
<Button
v-if="!$appConfigStore.isKioskMode"
class="button--share"
Expand All @@ -41,7 +41,7 @@
@click="handleCopySession"
/>
<template #popper> Copy link to chat session </template>
</VTooltip>
</VTooltip> -->
<Toast position="top-center" />
</template>
<template v-else>
Expand Down

0 comments on commit 87930f6

Please sign in to comment.