diff options
Diffstat (limited to 'Sora/Views')
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 10 | ||||
| -rw-r--r-- | Sora/Views/SearchSuggestionsView.swift | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 8e077c3..b665087 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -9,6 +9,7 @@ struct PostGridView: View { @State private var viewStates: [UUID: PostGridViewState] = [:] @State private var isSearchablePresented = false @State private var cachedSuggestions: [Either<BooruTag, BooruSearchQuery>] = [] + @State private var suppressNextSearchSubmit = false @Environment(\.isSearching) private var isSearching @@ -50,7 +51,8 @@ struct PostGridView: View { if settings.searchSuggestionsMode != .disabled { SearchSuggestionsView( items: searchSuggestionsItems(), - searchText: $manager.searchText + searchText: $manager.searchText, + suppressNextSearchSubmit: $suppressNextSearchSubmit ) } } @@ -62,6 +64,12 @@ struct PostGridView: View { } } .onSubmit(of: .search) { + if suppressNextSearchSubmit { + suppressNextSearchSubmit = false + + return + } + manager.performSearch(settings: settings) } .navigationDestination(for: BooruPost.self) { post in diff --git a/Sora/Views/SearchSuggestionsView.swift b/Sora/Views/SearchSuggestionsView.swift index c5210a6..03af4c6 100644 --- a/Sora/Views/SearchSuggestionsView.swift +++ b/Sora/Views/SearchSuggestionsView.swift @@ -8,6 +8,7 @@ struct SearchSuggestionsView: View { var items: [Either<BooruTag, BooruSearchQuery>] @Binding var searchText: String + @Binding var suppressNextSearchSubmit: Bool private var lastSearchTag: String { String(searchText.split(separator: " ").last ?? "").lowercased() @@ -58,6 +59,7 @@ struct SearchSuggestionsView: View { Button { let previousTags = searchText.split(separator: " ").dropLast() + suppressNextSearchSubmit = true searchText = (previousTags.map(String.init) + [tag.name]).joined(separator: " ") } label: { Text(tag.name) @@ -69,6 +71,7 @@ struct SearchSuggestionsView: View { { let previousTags = searchText.split(separator: " ").dropLast() + suppressNextSearchSubmit = true searchText = (previousTags.map(String.init) + [matchingTag]).joined(separator: " ") } } label: { |