From 937124fa61a023f79763091c28115ec387d16cd5 Mon Sep 17 00:00:00 2001 From: Dmitriymush Date: Tue, 13 Feb 2024 14:09:38 +0200 Subject: [PATCH] UI: added workaround for matChipInputAddOnBlur selection bug in tb-entity-subtype-list input --- .../components/entity/entity-subtype-list.component.html | 3 ++- .../components/entity/entity-subtype-list.component.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/shared/components/entity/entity-subtype-list.component.html b/ui-ngx/src/app/shared/components/entity/entity-subtype-list.component.html index 89c9b2ace8..26fb757c42 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-subtype-list.component.html +++ b/ui-ngx/src/app/shared/components/entity/entity-subtype-list.component.html @@ -31,9 +31,10 @@ style="max-width: 200px;" #entitySubtypeInput (focusin)="onFocus()" + (blur)="addOnBlur($event)" formControlName="entitySubtype" matAutocompleteOrigin - matChipInputAddOnBlur + matChipInputAddOnBlur="false" #origin="matAutocompleteOrigin" [matAutocompleteConnectedTo]="origin" [matAutocomplete]="entitySubtypeAutocomplete" diff --git a/ui-ngx/src/app/shared/components/entity/entity-subtype-list.component.ts b/ui-ngx/src/app/shared/components/entity/entity-subtype-list.component.ts index 9b49241d50..bc3cde24f5 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-subtype-list.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-subtype-list.component.ts @@ -262,6 +262,15 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, this.clear(''); } } + + addOnBlur(event: FocusEvent) { + if (!event.relatedTarget) { + return; + } + const value = this.entitySubtypeInput.nativeElement.value; + this.chipAdd({value} as MatChipInputEvent); + } + remove(entitySubtype: string) { const index = this.entitySubtypeList.indexOf(entitySubtype); if (index >= 0) {