diff --git a/projects/go-lib/src/lib/components/go-datepicker/go-datepicker.component.html b/projects/go-lib/src/lib/components/go-datepicker/go-datepicker.component.html index 6fdb64ea1..c95e53c00 100644 --- a/projects/go-lib/src/lib/components/go-datepicker/go-datepicker.component.html +++ b/projects/go-lib/src/lib/components/go-datepicker/go-datepicker.component.html @@ -17,7 +17,7 @@ [(ngModel)]="selectedDate" (blur)="validateDate()" [disabled]="control.disabled" - (input)="closeCalendar()" + (input)="onInputCloseCalendar()" (click)="toggleDatepicker($event)" /> { expect(component.goCalendar.isOpen).toBe(false); }); }); + + describe("onInputCloseCalendar", () => { + it('close the calendar when the user interacts with the date field by typing inside it. ', () => { + component.goCalendar.openCalendar(new Date()); + + component.onInputCloseCalendar(); + + expect(component.goCalendar.isOpen).toBe(false); + }); + }); + }); diff --git a/projects/go-lib/src/lib/components/go-datepicker/go-datepicker.component.ts b/projects/go-lib/src/lib/components/go-datepicker/go-datepicker.component.ts index bdb5a3043..cd74b1fbe 100644 --- a/projects/go-lib/src/lib/components/go-datepicker/go-datepicker.component.ts +++ b/projects/go-lib/src/lib/components/go-datepicker/go-datepicker.component.ts @@ -118,7 +118,8 @@ export class GoDatepickerComponent extends GoFormBaseComponent implements OnDest private initializePlaceholder(): void { this.placeholder = this.placeholder || LocaleFormat.format(this.locale); } - closeCalendar() { + + public onInputCloseCalendar(): void { if (this.goCalendar.isOpen) { this.goCalendar.closeCalendar(); }