From: Bill Erickson <berickxx@gmail.com> Date: Thu, 17 Oct 2019 21:44:40 +0000 (-0400) Subject: LP1830923 Combobox LP1844812 regression fix X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ad5882a7c3d6e5329b02237786c5dd89621b5822;p=evergreen%2Fequinox.git 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 <berickxx@gmail.com> Signed-off-by: Remington Steed <rjs7@calvin.edu> Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org> --- 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; } }