diff --git a/CHANGELOG.md b/CHANGELOG.md index 724dab33..990ff2b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Fixed +- Fixes an issue with Scroll problem on new messages with keyboard open [#1529](https://github.com/MessageKit/MessageKit/pull/1529) by [@politan8](https://github.com/politan8) + ### Added ### Changed diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index 8511c0f6..59e0926e 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.swift @@ -98,6 +98,10 @@ internal extension MessagesViewController { let newBottomInset = requiredScrollViewBottomInset(forKeyboardFrame: keyboardEndFrame) let differenceOfBottomInset = newBottomInset - messageCollectionViewBottomInset + UIView.performWithoutAnimation { + messageCollectionViewBottomInset = newBottomInset + } + if maintainPositionOnKeyboardFrameChanged && differenceOfBottomInset != 0 { let contentOffset = CGPoint(x: messagesCollectionView.contentOffset.x, y: messagesCollectionView.contentOffset.y + differenceOfBottomInset) // Changing contentOffset to bigger number than the contentSize will result in a jump of content @@ -107,10 +111,6 @@ internal extension MessagesViewController { } messagesCollectionView.setContentOffset(contentOffset, animated: false) } - - UIView.performWithoutAnimation { - messageCollectionViewBottomInset = newBottomInset - } } // MARK: - Inset Computation