mengxiong10 / vue2-datepicker

A datepicker / datetimepicker component for Vue2
https://mengxiong10.github.io/vue2-datepicker/index.html
MIT License
1.52k stars 407 forks source link

[Bug] time-picker keyboard input does not respect date value #560

Open RS-Sautter opened 3 years ago

RS-Sautter commented 3 years ago

Vue2-datepicker version: 3.8.1 Vue version: 2.6.12 Browser: Chrome 86

Steps to reproduce

  1. Set value for vue2-datepicker to now + 1day
  2. Set type to "time"
  3. Set disabled-date e.g. to: (date) => date < new Date()
  4. Now you can select a time value in the dropdown which is lower than the current time
  5. Bug: You cannot type in a time < now

Expected behavior You also can type in a time value < now, because it is for tomorrow.

Actual behavior It gets corrected to the previous value that was set.

Underlying Problem In l.242 of src/date-picker.js the backupTime is set to new Date(). This means that it tries to construct a date from your time input + the other values (year, month, day) of new Date(). This leads to the conflict with the disabled-date function.

RS-Sautter commented 3 years ago

561