Skip to content

Commit f0f112c

Browse files
authored
Merge pull request #548 from Esri/Caleb/Update-DisableAutoCorrect
[Fix] Search bugs
2 parents 9024cf0 + 49e992d commit f0f112c

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

Shared/Samples/Geocode offline/GeocodeOfflineView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct GeocodeOfflineView: View {
4646
var body: some View {
4747
GeocodeMapView(model: model, viewpoint: $viewpoint)
4848
.searchable(text: $searchText, prompt: "Type in an address")
49+
.autocorrectionDisabled()
4950
.onSubmit(of: .search) {
5051
submittedSearchText = searchText
5152
}

Shared/Samples/Query feature table/QueryFeatureTableView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ struct QueryFeatureTableView: View {
2929
MapView(map: model.map)
3030
.errorAlert(presentingError: $error)
3131
// Makes the search bar.
32-
.searchable(text: $searchBarText, prompt: Text("Search state names"))
32+
.searchable(text: $searchBarText, prompt: "Search state names")
33+
.autocorrectionDisabled()
3334
.onSubmit(of: .search) {
3435
model.currentQuery = searchBarText
3536
}

Shared/Samples/Search for web map/SearchForWebMapView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct SearchForWebMapView: View {
7474
placement: .navigationBarDrawer(displayMode: .always),
7575
prompt: "Web Maps"
7676
)
77+
.autocorrectionDisabled()
7778
.task(id: query) {
7879
// Load new results when the query changes.
7980
resultsAreLoading = true

Shared/Supporting Files/Views/CategoriesView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ private extension CategoriesView {
140140
}
141141
}
142142
.searchable(text: $query, placement: .navigationBarDrawer(displayMode: .always))
143+
.autocorrectionDisabled()
143144
.scrollDismissesKeyboard(.immediately)
144145
}
145146
}

Shared/Supporting Files/Views/FavoritesView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ private extension FavoritesView {
132132
}
133133
}
134134
.searchable(text: $query, placement: .navigationBarDrawer(displayMode: .always))
135+
.autocorrectionDisabled()
135136
}
136137
}
137138
}

Shared/Supporting Files/Views/SampleLink.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,15 @@ private extension String {
131131
/// - Parameter substring: The substring to bold.
132132
/// - Returns: The attributed string with the bolded substring.
133133
func boldingFirstOccurrence(of substring: String) -> AttributedString {
134-
if let range = localizedStandardRange(of: substring.trimmingCharacters(in: .whitespacesAndNewlines)),
135-
let boldedString = try? AttributedString(markdown: replacingCharacters(in: range, with: "**\(self[range])**")) {
136-
return boldedString
137-
} else {
138-
return AttributedString(self)
134+
var attributedString = AttributedString(self)
135+
136+
let trimmedSubstring = substring.trimmingCharacters(in: .whitespacesAndNewlines)
137+
if let range = localizedStandardRange(of: trimmedSubstring),
138+
let boldedSubstring = try? AttributedString(markdown: "**\(self[range])**"),
139+
let attributedRange = attributedString.range(of: self[range]) {
140+
attributedString.replaceSubrange(attributedRange, with: boldedSubstring)
139141
}
142+
143+
return attributedString
140144
}
141145
}

0 commit comments

Comments
 (0)