From 28f11c31b8aabbc936a590f538d464b577a8e3b3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 15 Aug 2019 11:40:06 -0400 Subject: [PATCH] LP1840050 Combobox reset on new entries Signed-off-by: Bill Erickson --- .../src/eg2/src/app/share/combobox/combobox.component.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts index de6831a6bc..9e7dc25f89 100644 --- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts +++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts @@ -75,11 +75,16 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { if (id) { if (this.entrylist.length) { this.selected = this.entrylist.filter(e => e.id === id)[0]; - } else { + } + + if (!this.selected) { + // It's possible the selected ID lives in a set of entries + // that are yet to be provided. this.startId = id; } } } + get selectedId(): any { return this.selected ? this.selected.id : null; } @@ -103,6 +108,9 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { @Input() set entries(el: ComboboxEntry[]) { if (el) { this.entrylist = el; + + // new set of entries essentially means a new instance. reset. + this.defaultSelectionApplied = false; this.applySelection(); // It's possible to provide an entrylist at load time, but @@ -187,8 +195,6 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { if (this.startId && this.entrylist && !this.defaultSelectionApplied) { - console.log('applyg select ' + this.startId); - const entry = this.entrylist.filter(e => e.id === this.startId)[0]; -- 2.11.0