From bf2ff59ade203902a60f7dd2dba05f11ebdd5550 Mon Sep 17 00:00:00 2001 From: Yusuf Suleman Date: Sat, 4 Apr 2026 12:02:39 -0500 Subject: [PATCH] feat: auto-focus search field when Quick Add opens in sheet Keyboard appears automatically when opening Quick Add from the food assistant sheet. 300ms delay lets the sheet animation finish first so the keyboard doesn't interfere with the presentation. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Platform/Features/Fitness/Views/FoodSearchView.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ios/Platform/Platform/Features/Fitness/Views/FoodSearchView.swift b/ios/Platform/Platform/Features/Fitness/Views/FoodSearchView.swift index 9079103..d15ab94 100644 --- a/ios/Platform/Platform/Features/Fitness/Views/FoodSearchView.swift +++ b/ios/Platform/Platform/Features/Fitness/Views/FoodSearchView.swift @@ -5,6 +5,7 @@ struct FoodSearchView: View { var onFoodAdded: (() -> Void)? @State private var vm = FoodSearchViewModel() @State private var selectedFood: Food? + @FocusState private var searchFocused: Bool var body: some View { VStack(spacing: 0) { @@ -15,6 +16,7 @@ struct FoodSearchView: View { TextField("Search foods...", text: $vm.searchText) .textFieldStyle(.plain) .autocorrectionDisabled() + .focused($searchFocused) if !vm.searchText.isEmpty { Button { vm.searchText = "" @@ -44,6 +46,11 @@ struct FoodSearchView: View { .background(Color.canvas) .task { await vm.loadInitial() + if isSheet { + // Small delay so sheet animation completes first + try? await Task.sleep(for: .milliseconds(300)) + searchFocused = true + } } .onChange(of: vm.searchText) { vm.search()