Skip to content

Commit

Permalink
Refactor FXIOS-10541 [Homepage Rebuild] Add keyboard dismissal logic …
Browse files Browse the repository at this point in the history
…to new homepage (#23759)

* Add tap gesture recognizer to dismiss keyboard

* move gesture recognizer to view did load instead of init
  • Loading branch information
Cramsden authored Dec 16, 2024
1 parent 8ac1e19 commit 394d238
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ final class HomepageViewController: UIViewController,

listenForThemeChange(view)
applyTheme()
addTapGestureRecognizerToDismissKeyboard()
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -452,13 +453,27 @@ final class HomepageViewController: UIViewController,
}
}

// MARK: Tap Geasutre Recognizer
private func addTapGestureRecognizerToDismissKeyboard() {
// We want any interaction with the homepage to dismiss the keyboard, including taps
let tap = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
tap.cancelsTouchesInView = false
view.addGestureRecognizer(tap)
}

@objc
private func dismissKeyboard() {
let action = ToolbarAction(windowUUID: windowUUID, actionType: ToolbarActionType.cancelEdit)
store.dispatch(action)
}

// MARK: Long Press (Photon Action Sheet)
private lazy var longPressRecognizer: UILongPressGestureRecognizer = {
return UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress))
}()

@objc
fileprivate func handleLongPress(_ longPressGestureRecognizer: UILongPressGestureRecognizer) {
private func handleLongPress(_ longPressGestureRecognizer: UILongPressGestureRecognizer) {
guard longPressGestureRecognizer.state == .began else { return }
// TODO: FXIOS-10613 - Pass proper action data to context menu
navigateToContextMenu()
Expand Down

0 comments on commit 394d238

Please sign in to comment.