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

View File

@ -133,6 +133,7 @@ struct TagManagementView: View {
.textFieldStyle(CustomTextFieldStyle())
.keyboardType(.default)
.autocorrectionDisabled(true)
.autocapitalization(.none)
.onSubmit {
onAddCustomTag()
}