Skip to content

Commit

Permalink
fix(legacy): InputTag fix pasting multiple invalid tags (#9340)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Oct 4, 2024
1 parent c0644f4 commit 8b8161d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions projects/legacy/components/input-tag/input-tag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
tuiRetargetedBoundaryCrossing,
} from '@taiga-ui/cdk/utils/dom';
import {tuiIsNativeFocusedIn} from '@taiga-ui/cdk/utils/focus';
import {tuiArrayRemove} from '@taiga-ui/cdk/utils/miscellaneous';
import {tuiArrayRemove, tuiIsString} from '@taiga-ui/cdk/utils/miscellaneous';
import type {TuiDataListHost} from '@taiga-ui/core/components/data-list';
import {
tuiAsDataListHost,
Expand Down Expand Up @@ -415,9 +415,14 @@ export class TuiInputTagComponent
.map((item) => this.clippedValue(item.trim()))
.filter((item, index, {length}) => item.length > 0 && index !== length - 1);
const validated = tags.filter((tag) => !this.disabledItemHandler(tag));
const invalid = tags.filter((tag) => this.disabledItemHandler(tag));

if (array.length > 1) {
this.updateSearch(this.clippedValue(array[array.length - 1]?.trim() ?? ''));
const search = invalid.length
? invalid.join(tuiIsString(this.separator) ? this.separator : ',')
: (array[array.length - 1]?.trim() ?? '');

this.updateSearch(this.clippedValue(search));
this.value = this.filterValue([...this.value, ...validated]);
} else {
this.updateSearch(this.clippedValue(value));
Expand Down

0 comments on commit 8b8161d

Please sign in to comment.