     override func keyboardWillShowAnimated(keyboardFrame frame: CGRect) {
         super.keyboardWillShowAnimated(keyboardFrame: frame)
 
-        chatInputViewBottomConstraint.update(offset: -frame.size.height)
-        view.layoutIfNeeded()
+        guard let constraint = chatInputViewBottomConstraint else {
+            return
+        }
+
+        constraint.update(offset: -frame.size.height)
+
+        if disableNextInputViewAnimation {
+            disableNextInputViewAnimation = false
+
+            UIView.setAnimationsEnabled(false)
+            view.layoutIfNeeded()
+            UIView.setAnimationsEnabled(true)
+        }
+        else {
+            view.layoutIfNeeded()
+        }
     }
 
     override func keyboardWillHideAnimated(keyboardFrame frame: CGRect) {
         super.keyboardWillHideAnimated(keyboardFrame: frame)
 
-        chatInputViewBottomConstraint.update(offset: 0.0)
-        view.layoutIfNeeded()
+        guard let constraint = chatInputViewBottomConstraint else {
+            return
+        }
+
+        constraint.update(offset: 0.0)
+
+        if disableNextInputViewAnimation {
+            disableNextInputViewAnimation = false
+
+            UIView.setAnimationsEnabled(false)
+            view.layoutIfNeeded()
+            UIView.setAnimationsEnabled(true)
+        }
+        else {
+            view.layoutIfNeeded()
+        }
     }
 
     override func viewDidLayoutSubviews() {


    fileprivate var tableViewTapGestureRecognizer: UITapGestureRecognizer!

    fileprivate var newMessageViewTopConstraint: Constraint!
    fileprivate var chatInputViewBottomConstraint: Constraint!

    fileprivate var newMessagesViewVisible = false

    /// Index path for cell with UIMenu presented.
    fileprivate var selectedMenuIndexPath: IndexPath?

    init(theme: Theme, chat: OCTChat, submanagerChats: OCTSubmanagerChats, submanagerObjects: OCTSubmanagerObjects, submanagerFiles: OCTSubmanagerFiles, delegate: ChatPrivateControllerDelegate) {
        self.theme = theme

        super.viewDidAppear(animated)

        if !chatInputView.text.isEmpty {
            disableNextInputViewAnimation = true
            _ = chatInputView.becomeFirstResponder()
        }
    }
