diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 2ee59fc07f..25df341d2d 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -515,6 +515,7 @@ class MainViewController: UIViewController { var keyboardShowing = false + private var didSendGestureDismissPixel: Bool = false @objc private func keyboardDidShow() { @@ -523,14 +524,16 @@ class MainViewController: UIViewController { @objc private func keyboardWillHide() { - if newTabPageViewController?.isDragging == true, keyboardShowing { + if !didSendGestureDismissPixel, newTabPageViewController?.isDragging == true, keyboardShowing { Pixel.fire(pixel: .addressBarGestureDismiss) + didSendGestureDismissPixel = true } } @objc private func keyboardDidHide() { keyboardShowing = false + didSendGestureDismissPixel = false } private func registerForPageRefreshPatterns() { diff --git a/DuckDuckGo/NewTabPageView.swift b/DuckDuckGo/NewTabPageView.swift index 219ddd9c27..0add43c1c9 100644 --- a/DuckDuckGo/NewTabPageView.swift +++ b/DuckDuckGo/NewTabPageView.swift @@ -76,7 +76,7 @@ struct NewTabPageView: View { .simultaneousGesture( DragGesture() .onChanged({ value in - if value.translation.height > 0 { + if value.translation.height != 0 { viewModel.beginDragging() } }) @@ -154,6 +154,8 @@ private extension NewTabPageView { EmptyView() } } + // Prevent recreating geomery reader when keyboard is shown/hidden. + .ignoresSafeArea(.keyboard) } @ViewBuilder diff --git a/DuckDuckGo/SimpleNewTabPageView.swift b/DuckDuckGo/SimpleNewTabPageView.swift index a228686ef5..a4fae0632b 100644 --- a/DuckDuckGo/SimpleNewTabPageView.swift +++ b/DuckDuckGo/SimpleNewTabPageView.swift @@ -49,7 +49,7 @@ struct SimpleNewTabPageView: View { .simultaneousGesture( DragGesture() .onChanged({ value in - if value.translation.height > 0 { + if value.translation.height != 0.0 { viewModel.beginDragging() } }) @@ -85,6 +85,8 @@ private extension SimpleNewTabPageView { } .withScrollKeyboardDismiss() } + // Prevent recreating geomery reader when keyboard is shown/hidden. + .ignoresSafeArea(.keyboard) } @ViewBuilder