LP1904036 date select emits on clear
authorBill Erickson <berickxx@gmail.com>
Thu, 15 Apr 2021 19:42:46 +0000 (15:42 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:31 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/share/date-select/date-select.component.html
Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts

index 07ce23f..9511091 100644 (file)
@@ -18,6 +18,7 @@
       [required]="required"
       (blur)="propagateTouch(); onDateEnter()"
       [(ngModel)]="current"
+      (ngModelChange)="inputChanged($event)"
       (keyup.enter)="onDateEnter()"
       (dateSelect)="onDateSelect($event)"/>
     <div class="input-group-append">
index 6d9e62d..5de9628 100644 (file)
@@ -112,6 +112,17 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
         this.propagateChange(date);
     }
 
+    // onDateSelect() is not called when the value is cleared.
+    // Handle that here.
+    inputChanged(value) {
+        if (value === null) {
+            this.onChangeAsDate.emit(null);
+            this.onChangeAsYmd.emit(null);
+            this.onChangeAsIso.emit(null);
+            this.propagateChange(null);
+        }
+    }
+
     reset() {
         this.current = {
             year: null,