UI: added workaround for matChipInputAddOnBlur selection bug in tb-entity-subtype-list input

This commit is contained in:
Dmitriymush 2024-02-13 14:09:38 +02:00
parent 2fb9b74bae
commit 937124fa61
2 changed files with 11 additions and 1 deletions

View File

@ -31,9 +31,10 @@
style="max-width: 200px;" style="max-width: 200px;"
#entitySubtypeInput #entitySubtypeInput
(focusin)="onFocus()" (focusin)="onFocus()"
(blur)="addOnBlur($event)"
formControlName="entitySubtype" formControlName="entitySubtype"
matAutocompleteOrigin matAutocompleteOrigin
matChipInputAddOnBlur matChipInputAddOnBlur="false"
#origin="matAutocompleteOrigin" #origin="matAutocompleteOrigin"
[matAutocompleteConnectedTo]="origin" [matAutocompleteConnectedTo]="origin"
[matAutocomplete]="entitySubtypeAutocomplete" [matAutocomplete]="entitySubtypeAutocomplete"

View File

@ -262,6 +262,15 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit,
this.clear(''); this.clear('');
} }
} }
addOnBlur(event: FocusEvent) {
if (!event.relatedTarget) {
return;
}
const value = this.entitySubtypeInput.nativeElement.value;
this.chipAdd({value} as MatChipInputEvent);
}
remove(entitySubtype: string) { remove(entitySubtype: string) {
const index = this.entitySubtypeList.indexOf(entitySubtype); const index = this.entitySubtypeList.indexOf(entitySubtype);
if (index >= 0) { if (index >= 0) {