Skip to content

Commit 759bf44

Browse files
authored
fix: prevent rendering placeholder for empty message list if messages are actually loaded (#2731)
1 parent d5f743b commit 759bf44

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/components/Channel/Channel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ const ChannelInner = (
326326
...initialState,
327327
hasMore: channel.state.messagePagination.hasPrev,
328328
loading: !channel.initialized,
329+
messages: channel.state.messages,
329330
},
330331
);
331332
const jumpToMessageFromSearch = useSearchFocusedMessage();

src/components/MessageList/VirtualizedMessageListComponents.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ export const EmptyPlaceholder = ({ context }: CommonVirtuosoComponentProps) => {
8787
const { EmptyStateIndicator = DefaultEmptyStateIndicator } = useComponentContext(
8888
'VirtualizedMessageList',
8989
);
90+
// prevent showing that there are no messages if there actually are messages (for some reason virtuoso decides to render empty placeholder first, even though it has the totalCount prop > 0)
91+
if (
92+
typeof context?.processedMessages !== 'undefined' &&
93+
context.processedMessages.length > 0
94+
)
95+
return null;
96+
9097
return (
9198
<>
9299
{EmptyStateIndicator && (

0 commit comments

Comments
 (0)