From c6e54e65367948863e32eebdba28dd4ad371a14e Mon Sep 17 00:00:00 2001 From: Terry Yiu Date: Sat, 12 Sep 2026 11:55:56 +0300 Subject: [PATCH] Add a way to dismiss the keyboard on iOS NumericField's .decimalPad/.numberPad keyboards have no Return/Done key of their own, and there was previously no way to dismiss them once shown. Tried .scrollDismissesKeyboard(.interactively) alone first, but it's unreliable in a Form: sections without .onMove/ .onDelete (Price Source, Bitcoin) don't consistently wire up the drag-to-dismiss gesture, so it only worked when dragging within the Currencies section. Adds a "Done" button to the keyboard toolbar as a deterministic fallback that works from any field, keeping the scroll dismissal too since it's a free bonus where it does work. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy --- iosApp/iosApp/ContentView.swift | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/iosApp/iosApp/ContentView.swift b/iosApp/iosApp/ContentView.swift index 50cf826..6689a00 100644 --- a/iosApp/iosApp/ContentView.swift +++ b/iosApp/iosApp/ContentView.swift @@ -26,7 +26,29 @@ struct ContentView: View { EditButton() } } + // NumericField's .decimalPad/.numberPad keyboards have no Return/Done key of + // their own (unlike a standard text keyboard). `.scrollDismissesKeyboard` alone + // isn't a reliable substitute here — Form's sections without .onMove/.onDelete + // (Price Source, Bitcoin) don't consistently wire up the drag-to-dismiss gesture, + // so it only ever worked when dragging within the Currencies section. This is a + // deterministic fallback that works regardless of which field is focused. + ToolbarItemGroup(placement: .keyboard) { + Spacer() + Button { + UIApplication.shared.sendAction( + #selector(UIResponder.resignFirstResponder), + to: nil, + from: nil, + for: nil + ) + } label: { + Text(IosLocalizationKt.localizedString(resource: MR.strings.shared.done)) + } + } } + // Kept alongside the Done button above: a free bonus in the Currencies section, + // where it does work reliably (see the toolbar comment for where it falls short). + .scrollDismissesKeyboard(.interactively) #endif } }