Skip to content

Commit fc6b5c4

Browse files
authored
Merge pull request #2378 from Akshat55/datepickr-onClose
feat: Emit an on close event
2 parents e216523 + f3ce5bd commit fc6b5c4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/datepicker/datepicker.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ export class DatePicker implements
238238

239239
@Output() valueChange: EventEmitter<any> = new EventEmitter();
240240

241+
/**
242+
* We are overriding onClose event even if users pass it via flatpickr options
243+
* Emits an event when date picker closes
244+
*/
245+
@Output() onClose: EventEmitter<any> = new EventEmitter();
246+
241247
protected _value = [];
242248

243249
protected _flatpickrOptions = {
@@ -253,7 +259,7 @@ export class DatePicker implements
253259
this.updateAttributes();
254260
this.updateCalendarListeners();
255261
},
256-
onClose: () => {
262+
onClose: (date) => {
257263
// This makes sure that the `flatpickrInstance selectedDates` are in sync with the values of
258264
// the inputs when the calendar closes.
259265
if (this.range && this.flatpickrInstance) {
@@ -272,6 +278,7 @@ export class DatePicker implements
272278
this.doSelect(this.flatpickrInstance.selectedDates);
273279
}
274280
}
281+
this.onClose.emit(date);
275282
},
276283
onDayCreate: (_dObj, _dStr, _fp, dayElem) => {
277284
dayElem.classList.add("bx--date-picker__day");

0 commit comments

Comments
 (0)