Skip to content

Commit 7d04a56

Browse files
feat(ios): dismiss keyboard on tap / scroll
Tapping empty space or scrolling now resigns first responder. Interactive controls consume their own taps, so fields and buttons keep working. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ba7a53d commit 7d04a56

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

ios/App/ContentView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ struct ContentView: View {
287287
.padding(.horizontal, 16)
288288
.padding(.top, 8)
289289
}
290+
// Dismiss the keyboard on a tap in empty space or on scroll.
291+
// Interactive controls consume their own taps, so fields/buttons
292+
// still work — only non-control taps fall through to here.
293+
.scrollDismissesKeyboard(.interactively)
294+
.onTapGesture { UIApplication.shared.endEditing() }
290295
.navigationTitle("mhrv-rs")
291296
.toolbar {
292297
ToolbarItem(placement: .navigationBarTrailing) {
@@ -1195,6 +1200,13 @@ class VpnManager: ObservableObject {
11951200

11961201
// MARK: — Helpers
11971202

1203+
extension UIApplication {
1204+
/// Resign first responder on whatever is focused — hides the keyboard.
1205+
func endEditing() {
1206+
sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
1207+
}
1208+
}
1209+
11981210
extension NEVPNStatus {
11991211
var displayName: String {
12001212
switch self {

0 commit comments

Comments
 (0)