From ad5882a7c3d6e5329b02237786c5dd89621b5822 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 17 Oct 2019 17:44:40 -0400 Subject: [PATCH] LP1830923 Combobox LP1844812 regression fix Allow a combobox to start with an empty array that is later filled by the caller. This was broken due to changes which prevented the combobox from seeing an empty/stub array as being different from its initialization array, thus ignoring empty array as a duplicate. Signed-off-by: Bill Erickson Signed-off-by: Remington Steed Signed-off-by: Galen Charlton --- Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 82c2c7bc97..ea49034a57 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 @@ -214,7 +214,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { } // Returns true if the 2 entries are equivalent. - entriesMatches(e1: ComboboxEntry, e2: ComboboxEntry): boolean { + entriesMatch(e1: ComboboxEntry, e2: ComboboxEntry): boolean { return ( e1 && e2 && e1.id === e2.id && @@ -225,12 +225,18 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { // Returns true if the 2 lists are equivalent. entrylistMatches(el: ComboboxEntry[]): boolean { + if (el.length === 0 && this.entrylist.length === 0) { + // Empty arrays are only equivalent if they are the same array, + // since the caller may provide an array that starts empty, but + // is later populated. + return el === this.entrylist; + } if (el.length !== this.entrylist.length) { return false; } for (let i = 0; i < el.length; i++) { const mine = this.entrylist[i]; - if (!mine || !this.entriesMatches(mine, el[i])) { + if (!mine || !this.entriesMatch(mine, el[i])) { return false; } } -- 2.11.0