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:
Ilyas Hallak 2025-09-17 13:36:36 +02:00
parent fbf840888a
commit ba74430d10
2 changed files with 9 additions and 3 deletions

View File

@ -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 = ""
} }

View File

@ -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()
} }