diff --git a/IceCubesApp/App/SideBarView.swift b/IceCubesApp/App/SideBarView.swift index fcf7cb3b..3173d8e0 100644 --- a/IceCubesApp/App/SideBarView.swift +++ b/IceCubesApp/App/SideBarView.swift @@ -97,6 +97,9 @@ struct SideBarView: View { private var tabsView: some View { ForEach(tabs) { tab in Button { + //ensure keyboard is always dismissed when selecting a tab + hideKeyboard() + if tab == selectedTab { popToRootTab = .other DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) { @@ -171,3 +174,10 @@ private struct SideBarIcon: View { } } } + +extension View { + func hideKeyboard() { + let resign = #selector(UIResponder.resignFirstResponder) + UIApplication.shared.sendAction(resign, to: nil, from: nil, for: nil) + } +}