tags-input: validate last value when pasting.

This commit is contained in:
John Livingston 2024-06-13 12:00:11 +02:00
parent 618dc6aeae
commit 38946121b7
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
1 changed files with 8 additions and 6 deletions

View File

@ -191,12 +191,14 @@ export class TagsInputElement extends LivechatElement {
values = values.map(v => v.trim()).filter(v => v !== '')
if (values.length > 0) {
// Keep last value in input if value doesn't finish with a separator
if (!newValue.match(/\s+$/m)?.[0]?.includes(this.separator)) {
target.value = values.pop() ?? ''
} else {
target.value = ''
}
// 20240613: i disable this code, i think it is not a good idea.
// // Keep last value in input if value doesn't finish with a separator
// if (!newValue.match(/\s+$/m)?.[0]?.includes(this.separator)) {
// target.value = values.pop() ?? ''
// } else {
// target.value = ''
// }
target.value = ''
// no duplicate
this.value = [...new Set([...this.value, ...values])]