Bug 35014: Only set time for enable-time flatpickr

This patch adds a check to the onChange function such that we only
attempt to set the default time on change for time enabled flatpickrs
when the date is entered manually.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2023-10-09 16:37:22 +01:00 committed by Tomas Cohen Arazi
parent 69a19fb526
commit 5b25b26f70
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -71,9 +71,13 @@
}); });
}, },
onChange: function( selectedDates, dateText, instance) { onChange: function( selectedDates, dateText, instance) {
let parsedDate = flatpickr.parseDate(dateText, instance.config.dateFormat); var thisInput = instance.input;
if ( !parsedDate.getHours() ) { let = accepts_time = $(thisInput).data('flatpickr-enable-time');
instance.setDate(selectedDates[0].setHours(23, 59, 0, 0)); if ( accepts_time ) {
let parsedDate = flatpickr.parseDate(dateText, instance.config.dateFormat);
if ( !parsedDate.getHours() ) {
instance.setDate(selectedDates[0].setHours(23, 59, 0, 0));
}
} }
}, },
onClose: function( selectedDates, dateText, instance) { onClose: function( selectedDates, dateText, instance) {