openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

sap.m.DateTimePicker: Uncaught Error: Date must not be in valid range (minDate and maxDate)

Open cgerold opened this issue 8 years ago • 1 comments

OpenUI5 version: 1.52

Browser/version (+device/version): Chrome 69

URL (minimal example if possible): https://jsbin.com/cufevi/edit?html,js,output

Steps to reproduce the problem:

  1. Open the minimal example https://jsbin.com/cufevi/edit?html,js,output
  2. Open the calendar popup of the date time picker

What is the expected result? The calendar popup opens

What happens instead? The calendar popup does not open. A JavaScript error occurs: Uncaught Error: Date must not be in valid range (minDate and maxDate);

Any other information? (attach screenshot if possible) The method DateTimePicker.prototype._fillDateRange calculates a wrong initial focus date. Given the following state:

  • The property maxDate is set to Tue Oct 23 2018 23:59:59
  • The property minDate is set to Tue Oct 16 2018 23:59:59
  • The property dateValue is not set
  • Today's date is Tue Oct 24 2018 11:00:00

The method DateTimePicker.prototype._fillDateRange tries to read the date value of the date time picker. As the date value is not set the method uses new Date() as initial focus date. Then the focus date is compared with the min date and the max date. But before the method adds one day to the max date: this._oMaxDate.getTime() + 86400000 /* one day in milliseconds */;

With this in mind the comparison looks like:

if (Tue Oct 24 2018 11:00:00 < Tue Oct 16 2018 23:59:59 || Tue Oct 24 2018 11:00:00 > Tue Oct 24 2018 15:27:00) { // set initial focus date to min date }

As the if statement does not become true, the date time picker tries to set today's date as initial focus date. But the today's date is of course not within the min max date range.

cgerold avatar Oct 24 '18 09:10 cgerold

Hello @cgerold ,

Thank you for sharing this finding. I've created an internal incident 1880654028. The status of the issue will be updated here in GitHub.

Regards, Georgi

ghristanov avatar Oct 25 '18 09:10 ghristanov