feat: Improve label input functionality
- Split label input on space to create multiple labels at once - Disable autocapitalization in tag search field - Prevent duplicate labels when adding multiple at once
This commit is contained in:
parent
fbf840888a
commit
ba74430d10
@ -73,10 +73,15 @@ class BookmarkLabelsViewModel {
|
|||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
func addLabel(to bookmarkId: String, label: String) async {
|
func addLabel(to bookmarkId: String, label: String) async {
|
||||||
let trimmedLabel = label.trimmingCharacters(in: .whitespacesAndNewlines)
|
let individualLabels = label
|
||||||
guard !trimmedLabel.isEmpty else { return }
|
.components(separatedBy: " ")
|
||||||
|
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||||
|
.filter { !$0.isEmpty }
|
||||||
|
.filter { !currentLabels.contains($0) }
|
||||||
|
|
||||||
await addLabels(to: bookmarkId, labels: [trimmedLabel])
|
guard !individualLabels.isEmpty else { return }
|
||||||
|
|
||||||
|
await addLabels(to: bookmarkId, labels: individualLabels)
|
||||||
newLabelText = ""
|
newLabelText = ""
|
||||||
searchText = ""
|
searchText = ""
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,6 +133,7 @@ struct TagManagementView: View {
|
|||||||
.textFieldStyle(CustomTextFieldStyle())
|
.textFieldStyle(CustomTextFieldStyle())
|
||||||
.keyboardType(.default)
|
.keyboardType(.default)
|
||||||
.autocorrectionDisabled(true)
|
.autocorrectionDisabled(true)
|
||||||
|
.autocapitalization(.none)
|
||||||
.onSubmit {
|
.onSubmit {
|
||||||
onAddCustomTag()
|
onAddCustomTag()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user