Browse Source

UI: Fixed focus for entity-key-list component after blur this component

pull/5066/head
Vladyslav_Prykhodko 5 years ago
committed by Andrew Shvayka
parent
commit
f325edef75
  1. 22
      ui-ngx/src/app/shared/components/entity/entity-keys-list.component.ts

22
ui-ngx/src/app/shared/components/entity/entity-keys-list.component.ts

@ -157,11 +157,11 @@ export class EntityKeysListComponent implements ControlValueAccessor, OnInit, Af
add(event: MatChipInputEvent): void { add(event: MatChipInputEvent): void {
if (!this.matAutocomplete.isOpen) { if (!this.matAutocomplete.isOpen) {
const value = event.value; const value = (event.value || '').trim();
if ((value || '').trim()) { if (value) {
this.addKey(value.trim()); this.addKey(value);
} }
this.clear(''); this.clear('', document.activeElement === this.keyInput.nativeElement);
} }
} }
@ -194,13 +194,15 @@ export class EntityKeysListComponent implements ControlValueAccessor, OnInit, Af
map((data) => data ? data : [])) : of([]); map((data) => data ? data : [])) : of([]);
} }
clear(value: string = '') { clear(value: string = '', emitEvent = true) {
this.keyInput.nativeElement.value = value; this.keyInput.nativeElement.value = value;
this.keysListFormGroup.get('key').patchValue(null, {emitEvent: true}); this.keysListFormGroup.get('key').patchValue(null, {emitEvent});
setTimeout(() => { if (emitEvent) {
this.keyInput.nativeElement.blur(); setTimeout(() => {
this.keyInput.nativeElement.focus(); this.keyInput.nativeElement.blur();
}, 0); this.keyInput.nativeElement.focus();
}, 0);
}
} }
} }

Loading…
Cancel
Save