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
|
||||
func addLabel(to bookmarkId: String, label: String) async {
|
||||
let trimmedLabel = label.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard !trimmedLabel.isEmpty else { return }
|
||||
let individualLabels = label
|
||||
.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 = ""
|
||||
searchText = ""
|
||||
}
|
||||
|
||||
@ -133,6 +133,7 @@ struct TagManagementView: View {
|
||||
.textFieldStyle(CustomTextFieldStyle())
|
||||
.keyboardType(.default)
|
||||
.autocorrectionDisabled(true)
|
||||
.autocapitalization(.none)
|
||||
.onSubmit {
|
||||
onAddCustomTag()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user