@@ -53,22 +53,19 @@ extension MessagesViewController {
5353 @objc
5454 private func handleKeyboardDidChangeState( _ notification: Notification ) {
5555 guard let keyboardEndFrame = notification. userInfo ? [ UIKeyboardFrameEndUserInfoKey] as? CGRect else { return }
56-
57- if ( keyboardEndFrame. origin. y + keyboardEndFrame. size. height) > UIScreen . main. bounds. height {
58- // Hardware keyboard is found
59- messageCollectionViewBottomInset = view. frame. size. height - keyboardEndFrame. origin. y - iPhoneXBottomInset
60- } else {
61- //Software keyboard is found
62- let afterBottomInset = keyboardEndFrame. height > keyboardOffsetFrame. height ? ( keyboardEndFrame. height - iPhoneXBottomInset) : keyboardOffsetFrame. height
63- let differenceOfBottomInset = afterBottomInset - messageCollectionViewBottomInset
64-
65- if maintainPositionOnKeyboardFrameChanged && differenceOfBottomInset != 0 {
66- let contentOffset = CGPoint ( x: messagesCollectionView. contentOffset. x, y: messagesCollectionView. contentOffset. y + differenceOfBottomInset)
67- messagesCollectionView. setContentOffset ( contentOffset, animated: false )
68- }
69-
70- messageCollectionViewBottomInset = afterBottomInset
56+
57+ guard !isMessagesControllerBeingDismissed else { return }
58+
59+ let newBottomInset = view. frame. height - keyboardEndFrame. minY - iPhoneXBottomInset
60+
61+ let differenceOfBottomInset = newBottomInset - messageCollectionViewBottomInset
62+
63+ if maintainPositionOnKeyboardFrameChanged && differenceOfBottomInset != 0 {
64+ let contentOffset = CGPoint ( x: messagesCollectionView. contentOffset. x, y: messagesCollectionView. contentOffset. y + differenceOfBottomInset)
65+ messagesCollectionView. setContentOffset ( contentOffset, animated: false )
7166 }
67+
68+ messageCollectionViewBottomInset = newBottomInset
7269 }
7370
7471 @objc
0 commit comments