Skip to content

Commit 952c125

Browse files
authored
fix: add ScrollToLatestMessageButton to ComponentContext (#3159)
1 parent 68efeb5 commit 952c125

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/components/MessageList/MessageList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343
} from '../../constants/limits';
4444
import { useLastOwnMessage } from './hooks/useLastOwnMessage';
4545
import { useReducedMotionPreference } from './hooks/useReducedMotionPreference';
46-
import { ScrollToLatestMessageButton } from './ScrollToLatestMessageButton';
46+
import { ScrollToLatestMessageButton as DefaultScrollToLatestMessageButton } from './ScrollToLatestMessageButton';
4747
import {
4848
NotificationList as DefaultNotificationList,
4949
useNotificationTarget,
@@ -128,6 +128,7 @@ const MessageListWithContext = (props: MessageListWithContextProps) => {
128128
MessageListWrapper = 'ul',
129129
NewMessageNotification = DefaultNewMessageNotification,
130130
NotificationList = DefaultNotificationList,
131+
ScrollToLatestMessageButton = DefaultScrollToLatestMessageButton,
131132
TypingIndicator = DefaultTypingIndicator,
132133
UnreadMessagesNotification = DefaultUnreadMessagesNotification,
133134
} = useComponentContext();

src/components/MessageList/ScrollToLatestMessageButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Badge } from '../Badge';
1111
import { Button } from '../Button';
1212
import { IconArrowDown } from '../Icons';
1313

14-
type ScrollToLatestMessageButtonProps = {
14+
export type ScrollToLatestMessageButtonProps = {
1515
/** When true, user has jumped to an older message set and newer messages can be loaded */
1616
isNotAtLatestMessageSet?: boolean;
1717
isMessageListScrolledToBottom?: boolean;

src/components/MessageList/VirtualizedMessageList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ import {
4141
} from './VirtualizedMessageListComponents';
4242

4343
import {
44+
ScrollToLatestMessageButton as DefaultScrollToLatestMessageButton,
4445
UnreadMessagesSeparator as DefaultUnreadMessagesSeparator,
45-
ScrollToLatestMessageButton,
4646
} from '../MessageList';
4747
import { DateSeparator as DefaultDateSeparator } from '../DateSeparator';
4848
import { EventComponent as DefaultMessageSystem } from '../EventComponent';
@@ -253,6 +253,7 @@ const VirtualizedMessageListWithContext = (
253253
MessageSystem = DefaultMessageSystem,
254254
NewMessageNotification = DefaultNewMessageNotification,
255255
NotificationList = DefaultNotificationList,
256+
ScrollToLatestMessageButton = DefaultScrollToLatestMessageButton,
256257
TypingIndicator,
257258
UnreadMessagesNotification = DefaultUnreadMessagesNotification,
258259
UnreadMessagesSeparator = DefaultUnreadMessagesSeparator,

src/context/ComponentContext.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
type ReactionSelectorProps,
4848
type RecordingPermissionDeniedNotificationProps,
4949
type ReminderNotificationProps,
50+
type ScrollToLatestMessageButtonProps,
5051
type SearchResultsPresearchProps,
5152
type SearchSourceResultListProps,
5253
type SendButtonProps,
@@ -185,6 +186,8 @@ export type ComponentContextValue = {
185186
NotificationList?: React.ComponentType<NotificationListProps>;
186187
/** Custom UI component to display a notification when scrolled up the list and new messages arrive, defaults to and accepts same props as [NewMessageNotification](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageList/NewMessageNotification.tsx) */
187188
NewMessageNotification?: React.ComponentType<NewMessageNotificationProps>;
189+
/** Custom UI component to display the scroll-to-latest-message button in a `MessageList`, defaults to and accepts same props as: [ScrollToLatestMessageButton](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageList/ScrollToLatestMessageButton.tsx) */
190+
ScrollToLatestMessageButton?: React.ComponentType<ScrollToLatestMessageButtonProps>;
188191
/** Custom UI component to display message replies, defaults to and accepts same props as: [MessageRepliesCountButton](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageRepliesCountButton.tsx) */
189192
MessageRepliesCountButton?: React.ComponentType<MessageRepliesCountButtonProps>;
190193
/** Custom UI component to display message delivery status, defaults to and accepts same props as: [MessageStatus](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageStatus.tsx) */

0 commit comments

Comments
 (0)