Skip to content

Commit 06d1098

Browse files
authored
fix: render typing indicator outside the VirtualizedMessageList scroll container (#2406)
BREAKING CHANGE: The VirtualizedMessageList does not provide default Footer component BREAKING CHANGE: The VirtualizedMessageList markup has changed as TypingIndicator is rendered as a child of MessageListMainPanel
1 parent 7919438 commit 06d1098

4 files changed

+3
-29
lines changed

src/components/MessageList/VirtualizedMessageList.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import {
3737
calculateFirstItemIndex,
3838
calculateItemIndex,
3939
EmptyPlaceholder,
40-
Footer,
4140
Header,
4241
Item,
4342
makeItemsRenderedHandler,
@@ -232,6 +231,7 @@ const VirtualizedMessageListWithContext = <
232231
UnreadMessagesNotification = DefaultUnreadMessagesNotification,
233232
UnreadMessagesSeparator,
234233
VirtualMessage: MessageUIComponentFromContext = MessageSimple,
234+
TypingIndicator,
235235
} = useComponentContext<StreamChatGenerics>('VirtualizedMessageList');
236236
const MessageUIComponent = MessageUIComponentFromProps || MessageUIComponentFromContext;
237237

@@ -435,7 +435,6 @@ const VirtualizedMessageListWithContext = <
435435
className='str-chat__message-list-scroll'
436436
components={{
437437
EmptyPlaceholder,
438-
Footer,
439438
Header,
440439
Item,
441440
...virtuosoComponentsFromProps,
@@ -490,6 +489,7 @@ const VirtualizedMessageListWithContext = <
490489
{...(defaultItemHeight ? { defaultItemHeight } : {})}
491490
/>
492491
</div>
492+
{TypingIndicator && <TypingIndicator />}
493493
</MessageListMainPanel>
494494
<MessageListNotifications
495495
hasNewMessages={newMessagesNotification}

src/components/MessageList/VirtualizedMessageListComponents.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,7 @@ export const EmptyPlaceholder = <
108108
</>
109109
);
110110
};
111-
export const Footer = <
112-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
113-
>() => {
114-
const { TypingIndicator } = useComponentContext<StreamChatGenerics>('VirtualizedMessageList');
115-
return TypingIndicator ? <TypingIndicator /> : null;
116-
};
111+
117112
export const messageRenderer = <
118113
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
119114
>(

src/components/MessageList/__tests__/VirtualizedMessageListComponents.test.js

-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import '@testing-library/jest-dom';
33
import { render, screen } from '@testing-library/react';
44
import {
55
EmptyPlaceholder,
6-
Footer,
76
Header,
87
Item,
98
messageRenderer,
@@ -206,25 +205,6 @@ describe('VirtualizedMessageComponents', () => {
206205
});
207206
});
208207

209-
describe('Footer', () => {
210-
it('should render nothing in Footer by default', () => {
211-
const { container } = renderElements(<Footer />);
212-
expect(container).toMatchInlineSnapshot(`<div />`);
213-
});
214-
it('should render custom TypingIndicator in Footer', () => {
215-
const TypingIndicator = () => <div>Custom TypingIndicator</div>;
216-
const componentContext = { TypingIndicator };
217-
const { container } = renderElements(<Footer />, componentContext);
218-
expect(container).toMatchInlineSnapshot(`
219-
<div>
220-
<div>
221-
Custom TypingIndicator
222-
</div>
223-
</div>
224-
`);
225-
});
226-
});
227-
228208
describe('messageRenderer', () => {
229209
const virtuosoIndex = PREPEND_OFFSET;
230210
const numItemsPrepended = 0;

src/components/MessageList/__tests__/__snapshots__/VirtualizedMessageList.test.js.snap

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ exports[`VirtualizedMessageList should render the list without any message 1`] =
6464
No chats here yet…
6565
</p>
6666
</div>
67-
<div />
6867
</div>
6968
</div>
7069
</div>

0 commit comments

Comments
 (0)