Skip to content

Commit

Permalink
Merge pull request #548 from Esri/Caleb/Update-DisableAutoCorrect
Browse files Browse the repository at this point in the history
[Fix] Search bugs
  • Loading branch information
CalebRas authored Nov 15, 2024
2 parents 9024cf0 + 49e992d commit f0f112c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions Shared/Samples/Geocode offline/GeocodeOfflineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct GeocodeOfflineView: View {
var body: some View {
GeocodeMapView(model: model, viewpoint: $viewpoint)
.searchable(text: $searchText, prompt: "Type in an address")
.autocorrectionDisabled()
.onSubmit(of: .search) {
submittedSearchText = searchText
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ struct QueryFeatureTableView: View {
MapView(map: model.map)
.errorAlert(presentingError: $error)
// Makes the search bar.
.searchable(text: $searchBarText, prompt: Text("Search state names"))
.searchable(text: $searchBarText, prompt: "Search state names")
.autocorrectionDisabled()
.onSubmit(of: .search) {
model.currentQuery = searchBarText
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct SearchForWebMapView: View {
placement: .navigationBarDrawer(displayMode: .always),
prompt: "Web Maps"
)
.autocorrectionDisabled()
.task(id: query) {
// Load new results when the query changes.
resultsAreLoading = true
Expand Down
1 change: 1 addition & 0 deletions Shared/Supporting Files/Views/CategoriesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private extension CategoriesView {
}
}
.searchable(text: $query, placement: .navigationBarDrawer(displayMode: .always))
.autocorrectionDisabled()
.scrollDismissesKeyboard(.immediately)
}
}
Expand Down
1 change: 1 addition & 0 deletions Shared/Supporting Files/Views/FavoritesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ private extension FavoritesView {
}
}
.searchable(text: $query, placement: .navigationBarDrawer(displayMode: .always))
.autocorrectionDisabled()
}
}
}
14 changes: 9 additions & 5 deletions Shared/Supporting Files/Views/SampleLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,15 @@ private extension String {
/// - Parameter substring: The substring to bold.
/// - Returns: The attributed string with the bolded substring.
func boldingFirstOccurrence(of substring: String) -> AttributedString {
if let range = localizedStandardRange(of: substring.trimmingCharacters(in: .whitespacesAndNewlines)),
let boldedString = try? AttributedString(markdown: replacingCharacters(in: range, with: "**\(self[range])**")) {
return boldedString
} else {
return AttributedString(self)
var attributedString = AttributedString(self)

let trimmedSubstring = substring.trimmingCharacters(in: .whitespacesAndNewlines)
if let range = localizedStandardRange(of: trimmedSubstring),
let boldedSubstring = try? AttributedString(markdown: "**\(self[range])**"),
let attributedRange = attributedString.range(of: self[range]) {
attributedString.replaceSubrange(attributedRange, with: boldedSubstring)
}

return attributedString
}
}

0 comments on commit f0f112c

Please sign in to comment.