Skip to content

Document the MessagesCollectionView scroll methods - #1929

Merged
martinpucik merged 2 commits into
MessageKit:mainfrom
martinpucik:claude/dreamy-keller-3e6zgm
Nov 1, 2026
Merged

martinpucik merged 2 commits into
MessageKit:mainfrom
martinpucik:claude/dreamy-keller-3e6zgm

Conversation

@martinpucik

Copy link
Copy Markdown
Contributor

What does this implement/fix? Explain your changes.

scrollToLastItem(at:animated:), scrollToBottom(animated:) and reloadDataAndKeepOffset() on MessagesCollectionView had no documentation. That left people unsure why scrollToLastItem stops with a gap under the newest message, and unaware that scrollToBottom exists to scroll past it.

  • Add doc comments to the three methods. They explain that scrollToLastItem lines the last cell up with the bottom of the visible area, which keeps the layout's sectionInset.bottom out of view, while scrollToBottom scrolls past that inset to the end of the content. They also say when MessagesViewController calls scrollToLastItem itself.
  • Replace the stale note on scrollsToLastItemOnKeyboardBeginsEditing. It pointed at "the below flag related to scrollToBottom", and that flag no longer exists.
  • Remove the // NOTE that pointed at Random crash when calling scrollToBottom with "Invalid update: invalid number of items in section 0" #725. That issue was a closed batch-update crash, not a limitation of the method.
  • Add a FAQ entry, "How can I scroll to the newest message?", with an example, and add a CHANGELOG entry.

Only comments and docs change. There is no change in behaviour.

Does this close any currently open issues?

It answers the question in #1874 and #1830, though neither is closed by it: those issues ask about the behaviour, and this PR documents it rather than changing it.

Any relevant logs, error output, etc?

None.

Any other comments?

The open PR #1832 changes the body of scrollToLastItem. This PR touches only the comment lines above that method, so if both are merged, any conflict will be limited to those comment lines.

Where has this been tested?

Devices/Simulators: N/A. Only documentation and comments change.

iOS Version: N/A

Swift Version: N/A

MessageKit Version: main


Generated by Claude Code

scrollToLastItem(at:animated:), scrollToBottom(animated:) and
reloadDataAndKeepOffset() had no documentation, so it was unclear why
scrollToLastItem leaves the bottom section inset out of view (MessageKit#1874,
MessageKit#1830) and that scrollToBottom exists to scroll past it. Add doc
comments, replace the stale note on
scrollsToLastItemOnKeyboardBeginsEditing that pointed at a flag that no
longer exists, and add a FAQ entry on scrolling to the newest message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kdtqz9Dvfv2BXcyucfWtkK
@martinpucik
martinpucik enabled auto-merge November 1, 2026 21:18
@martinpucik
martinpucik merged commit cbf2464 into MessageKit:main Nov 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants