material-datetime-picker icon indicating copy to clipboard operation
material-datetime-picker copied to clipboard

Setting a default time with 58 or 59 minutes makes the picker fail to open

Open pinklady6 opened this issue 7 years ago • 1 comments

When I use the configuration options to set a default time and that time rounds up to 60 minutes the picker fails to open because this line

this.$('.js-clock-minutes .' + this.options.styles.clockNum + '[data-number="' + minuteAsInt + '"]').classList.add(this.options.styles.clockNum + '--active');

Is looking for a component where minutesAsInt is 60 when it really should be 0

I hacked around this by adding another set for the minutes after they are reset on m

  var m = moment(time);
  var minuteAsInt = Math.round(parseInt(m.format('mm'), 10) / 5) * 5;
  m.minutes(minuteAsInt);
  minuteAsInt = parseInt(m.format('mm')); //Work around rounding to 60, this sets minuteAsInt to 0

pinklady6 avatar Dec 20 '17 15:12 pinklady6

This is not just the default, even if I set the value to moment.endOf("day") I get the same error.

Uncaught TypeError: Cannot read property 'classList' of undefined
    at DateTimePicker.setTime (material-datetime-picker.mjs:699)
    at DateTimePicker.open (material-datetime-picker.mjs:321)
    at DateTimeSelector.onDateRangeSelectClick (DateTimeSelector.tsx:76)
    at HTMLUnknownElement.callCallback (react-dom.development.js:145)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:195)
    at invokeGuardedCallback (react-dom.development.js:248)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:262)
    at executeDispatch (react-dom.development.js:593)
    at executeDispatchesInOrder (react-dom.development.js:615)
    at executeDispatchesAndRelease (react-dom.development.js:713)

kayleighbray avatar Jan 10 '19 17:01 kayleighbray