LP1888723 Combobox avoids clearing selected for freetext
authorBill Erickson <berickxx@gmail.com>
Mon, 14 Sep 2020 18:27:34 +0000 (14:27 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Sun, 15 Aug 2021 23:55:24 +0000 (19:55 -0400)
Follow-up to LP#1850547: Avoid clearing the selected item in the
combobox when selectedId is set to null in cases where freetext is
enabled and a freetext value is present.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts

index a5ef960..fb2d81b 100644 (file)
@@ -298,7 +298,16 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie
         if (!firstTime) {
             if ('selectedId' in changes) {
                 if (!changes.selectedId.currentValue) {
-                    this.selected = null;
+
+                    // In allowFreeText mode, selectedId will be null even
+                    // though a freetext value may be present in the combobox.
+                    if (this.allowFreeText) {
+                        if (this.selected && !this.selected.freetext) {
+                            this.selected = null;
+                        }
+                    } else {
+                        this.selected = null;
+                    }
                 }
             }
             if ('idlClass' in changes) {