diff --git a/CHANGELOG.md b/CHANGELOG.md index 28776005..f3e811f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Messaging UI: Users can tap any where on the conversation screen to close the keyboard. + ### Fixed diff --git a/Sources/NablaMessagingUI/Scenes/Conversation/UI/ConversationViewController.swift b/Sources/NablaMessagingUI/Scenes/Conversation/UI/ConversationViewController.swift index cc010eae..056276fb 100644 --- a/Sources/NablaMessagingUI/Scenes/Conversation/UI/ConversationViewController.swift +++ b/Sources/NablaMessagingUI/Scenes/Conversation/UI/ConversationViewController.swift @@ -180,6 +180,16 @@ final class ConversationViewController: UIViewController, ConversationViewContra // TODO: @tgy - Don't retain modules private lazy var imagePickerModule = ImagePickerModule(delegate: self) + private lazy var tapGesture: UIGestureRecognizer = { + let recognizer = UITapGestureRecognizer(target: self, action: #selector(tapGestureHandler)) + recognizer.cancelsTouchesInView = false + return recognizer + }() + + @objc private func tapGestureHandler() { + view.endEditing(true) + } + private func initialize() { hidesBottomBarWhenPushed = true @@ -191,6 +201,8 @@ final class ConversationViewController: UIViewController, ConversationViewContra ?? UINavigationBarAppearance() scrollEdgeAppearance.configureWithDefaultBackground() navigationItem.scrollEdgeAppearance = scrollEdgeAppearance + + collectionView.addGestureRecognizer(tapGesture) } private func setUp() {