Send change event on flatpickr widget close

This commit is contained in:
Jean-Baptiste Bellet
2022-10-05 10:33:11 +02:00
committed by Konrad
parent 263b36d1d9
commit f5ebc797c4

View File

@@ -62,7 +62,7 @@ export default class extends Flatpickr {
}
change(selectedDates, dateStr, instance) {
if (this.hasStartTarget && this.hasEndTarget) {
if (this.hasStartTarget && this.hasEndTarget && this.modeValue == "range") {
this.startTarget.value = selectedDates[0]
? this.fp.formatDate(selectedDates[0], this.config.dateFormat)
: "";
@@ -78,6 +78,11 @@ export default class extends Flatpickr {
}
}
close() {
// Send a change event to the input element to trigger the ng-change
this.hasEndTarget && this.endTarget.dispatchEvent(new Event("change"));
}
// private
plugins = (mode, datetimepicker) => {