Fix adding tags on android

This commit is contained in:
Chocobozzz 2024-10-02 16:07:27 +02:00
parent 017b8e3b39
commit 5801d519a7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 16 additions and 3 deletions

View File

@ -5,4 +5,5 @@
[inputId]="inputId"
[allowDuplicate]="false"
[caseSensitiveDuplication]="false"
[separator]="separator"
></p-chips>

View File

@ -1,5 +1,7 @@
import { Component, Input, forwardRef } from '@angular/core'
import { CommonModule } from '@angular/common'
import { Component, Input, OnInit, forwardRef } from '@angular/core'
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
import { isMobile } from '@root-helpers/web-browser'
import { ChipsModule } from 'primeng/chips'
@Component({
@ -13,14 +15,24 @@ import { ChipsModule } from 'primeng/chips'
}
],
standalone: true,
imports: [ ChipsModule, FormsModule ]
imports: [ CommonModule, ChipsModule, FormsModule ]
})
export class SelectTagsComponent implements ControlValueAccessor {
export class SelectTagsComponent implements OnInit, ControlValueAccessor {
@Input({ required: true }) inputId: string
@Input() availableItems: string[] = []
@Input() selectedItems: string[] = []
@Input() placeholder = $localize`Enter a new tag`
separator: string
ngOnInit () {
// FIXME: workaround for https://github.com/primefaces/primeng/issues/13981
if (isMobile()) {
this.separator = ','
this.placeholder = $localize`Use a comma (,) to add a tag`
}
}
propagateChange = (_: any) => { /* empty */ }
writeValue (items: string[]) {