UI: Fix incorrect add chip for autocomplete component

This commit is contained in:
Vladyslav_Prykhodko 2021-08-12 13:19:37 +03:00
parent f325edef75
commit 53a919e046
3 changed files with 4 additions and 8 deletions

View File

@ -37,7 +37,6 @@
[matAutocomplete]="labelAutocomplete"
[matChipInputFor]="chipList"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
matChipInputAddOnBlur
(matChipInputTokenEnd)="add($event)">
</mat-chip-list>
<mat-autocomplete #labelAutocomplete="matAutocomplete"

View File

@ -36,7 +36,6 @@
[matAutocomplete]="entitySubtypeAutocomplete"
[matChipInputFor]="chipList"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
matChipInputAddOnBlur
(matChipInputTokenEnd)="chipAdd($event)">
</mat-chip-list>
<mat-autocomplete #entitySubtypeAutocomplete="matAutocomplete"

View File

@ -203,7 +203,7 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit,
this.dirty = true;
}
add(entitySubtype: string): void {
private add(entitySubtype: string): void {
if (!this.modelValue || this.modelValue.indexOf(entitySubtype) === -1) {
if (!this.modelValue) {
this.modelValue = [];
@ -213,13 +213,12 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit,
this.entitySubtypeListFormGroup.get('entitySubtypeList').setValue(this.entitySubtypeList);
}
this.propagateChange(this.modelValue);
this.clear();
}
chipAdd(event: MatChipInputEvent): void {
const value = event.value;
if ((value || '').trim()) {
this.add(value.trim());
const value = (event.value || '').trim();
if (value) {
this.add(value);
}
this.clear('');
}
@ -234,7 +233,6 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit,
this.modelValue = null;
}
this.propagateChange(this.modelValue);
this.clear();
}
}