Skip to content

Commit

Permalink
[FR-46] fix: The ScrollBottomHandlerButton is displayed even when t…
Browse files Browse the repository at this point in the history
…he chat message is empty.
  • Loading branch information
agatha197 committed Jan 6, 2025
1 parent e2c145d commit 68f2bc5
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions react/src/components/lablupTalkativotUI/VirtualChatMessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,44 +81,46 @@ const VirtualChatMessageList: React.FC<VirtualizedListProps> = ({
overscan={overscan}
ref={virtuosoRef}
/>
<div
style={{
position: 'absolute',
right: '50%',
transform: 'translateX(+50%)',
bottom: token.marginSM,
opacity: atBottom ? 0 : 1,
transition: 'opacity 0.2s',
transitionDelay: atBottom ? '0s' : '0.2s',
}}
>
<ScrollBottomHandlerButton
atBottom={atBottom}
autoScroll={isStreaming}
onScrollToBottom={(type) => {
const virtuoso = virtuosoRef.current;
switch (type) {
case 'auto': {
virtuoso?.scrollToIndex({
align: 'end',
behavior: 'auto',
index: 'LAST',
});
break;
}
case 'click': {
virtuoso?.scrollToIndex({
align: 'end',
behavior: 'smooth',
index: 'LAST',
});
break;
}
}
{!_.isEmpty(messages) && (
<div
style={{
position: 'absolute',
right: '50%',
transform: 'translateX(+50%)',
bottom: token.marginSM,
opacity: atBottom ? 0 : 1,
transition: 'opacity 0.2s',
transitionDelay: atBottom ? '0s' : '0.2s',
}}
lastMessageContent={_.get(_.last(messages), 'content')}
/>
</div>
>
<ScrollBottomHandlerButton
atBottom={atBottom}
autoScroll={isStreaming}
onScrollToBottom={(type) => {
const virtuoso = virtuosoRef.current;
switch (type) {
case 'auto': {
virtuoso?.scrollToIndex({
align: 'end',
behavior: 'auto',
index: 'LAST',
});
break;
}
case 'click': {
virtuoso?.scrollToIndex({
align: 'end',
behavior: 'smooth',
index: 'LAST',
});
break;
}
}
}}
lastMessageContent={_.get(_.last(messages), 'content')}
/>
</div>
)}
</Flex>
);
};
Expand Down

0 comments on commit 68f2bc5

Please sign in to comment.