From a199d8b3bc4577f7e4094a2f2be5930a4b02a8df Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 11 May 2022 18:24:40 -0700 Subject: [PATCH] keep search field focus when clearing search text --- .../OmnivoreKit/Sources/Views/SearchBar.swift | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Views/SearchBar.swift b/apple/OmnivoreKit/Sources/Views/SearchBar.swift index 81edaa3c6..7c7e02a4f 100644 --- a/apple/OmnivoreKit/Sources/Views/SearchBar.swift +++ b/apple/OmnivoreKit/Sources/Views/SearchBar.swift @@ -26,26 +26,31 @@ public struct SearchBar: View { .padding(.leading, 10) if self.searchTerm != "" { - Button(action: { - self.searchTerm = "" - self.isFocused = false - }) { - Image(systemName: "multiply.circle.fill") - .foregroundColor(.gray) - .padding(.trailing, 8) - } + Button( + action: { + self.searchTerm = "" + }, + label: { + Image(systemName: "multiply.circle.fill") + .foregroundColor(.gray) + .padding(.trailing, 8) + } + ) } } ) .padding(.horizontal, 10) if isFocused { - Button(action: { - self.isFocused = false - self.searchTerm = "" - }) { - Text("Cancel") - } + Button( + action: { + self.searchTerm = "" + self.isFocused = false + }, + label: { + Text("Cancel") + } + ) .padding(.trailing, 10) .transition(.move(edge: .trailing)) }