ChannelMessageList and UserMessageList: scroll to bottom onFirstAppear

This commit is contained in:
Mike Robbins 2025-10-14 17:02:58 -04:00
parent ee1a7c4415
commit e0f0b4a0f7
2 changed files with 6 additions and 0 deletions

View file

@ -130,6 +130,9 @@ struct ChannelMessageList: View {
.defaultScrollAnchorTopAlignment()
.defaultScrollAnchorBottomSizeChanges()
.scrollDismissesKeyboard(.immediately)
.onFirstAppear {
debouncedScrollToBottom(scrollView: scrollView, lastMessageId: lastMessageId, delay: 0.1)
}
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { _ in
// Keyboard is about to appear: keyboard show animation hasn't quite started yet.
// Schedule an immediate scroll to the bottom message by its messageId, in order to force LazyVStack to render that cell if it isn't rendered already

View file

@ -128,6 +128,9 @@ struct UserMessageList: View {
.defaultScrollAnchorTopAlignment()
.defaultScrollAnchorBottomSizeChanges()
.scrollDismissesKeyboard(.immediately)
.onFirstAppear {
debouncedScrollToBottom(scrollView: scrollView, lastMessageId: lastMessageId, delay: 0.1)
}
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { _ in
// Keyboard is about to appear: keyboard show animation hasn't quite started yet.
// Schedule an immediate scroll to the bottom message by its messageId, in order to force LazyVStack to render that cell if it isn't rendered already