diff --git a/src/pretix/static/pretixcontrol/js/ui/main.js b/src/pretix/static/pretixcontrol/js/ui/main.js index 776751d1bf..95b2827a1c 100644 --- a/src/pretix/static/pretixcontrol/js/ui/main.js +++ b/src/pretix/static/pretixcontrol/js/ui/main.js @@ -196,7 +196,15 @@ var form_handlers = function (el) { } if ($(this).is('[data-is-payment-date]')) opts["daysOfWeekDisabled"] = JSON.parse($("body").attr("data-payment-weekdays-disabled")); - $(this).datetimepicker(opts); + $(this).datetimepicker(opts).on("dp.hide", function() { + // when min/max is used in datetimepicker, closing and re-opening the picker opens at the wrong date + // therefore keep the current viewDate and re-set it after datetimepicker is done hiding + var $dtp = $(this).data("DateTimePicker"); + var currentViewDate = $dtp.viewDate(); + window.setTimeout(function () { + $dtp.viewDate(currentViewDate); + }, 50); + }); if ($(this).parent().is('.splitdatetimerow')) { $(this).on("dp.change", function (ev) { var $timepicker = $(this).closest(".splitdatetimerow").find(".timepickerfield"); diff --git a/src/pretix/static/pretixpresale/js/ui/main.js b/src/pretix/static/pretixpresale/js/ui/main.js index fe94fc8760..9cded15a3a 100644 --- a/src/pretix/static/pretixpresale/js/ui/main.js +++ b/src/pretix/static/pretixpresale/js/ui/main.js @@ -82,7 +82,15 @@ var form_handlers = function (el) { Math.abs(+new Date(opts.minDate) - new Date()) < Math.abs(+new Date(opts.maxDate) - new Date()) ) ? opts.minDate : opts.maxDate; } - $(this).datetimepicker(opts); + $(this).datetimepicker(opts).on("dp.hide", function() { + // when min/max is used in datetimepicker, closing and re-opening the picker opens at the wrong date + // therefore keep the current viewDate and re-set it after datetimepicker is done hiding + var $dtp = $(this).data("DateTimePicker"); + var currentViewDate = $dtp.viewDate(); + window.setTimeout(function () { + $dtp.viewDate(currentViewDate); + }, 50); + }); if ($(this).parent().is('.splitdatetimerow')) { $(this).on("dp.change", function (ev) { var $timepicker = $(this).closest(".splitdatetimerow").find(".timepickerfield");