vue2-datepicker: confirm: value doesn't change on "OK", if only year and/or month were changed

The month and year of a date cannot currently be changed alone (using the UI).

Steps to reproduce

  1. <date-picker v-model="value" confirm />
  2. Choose a date, e.g. 2019-04-07.
  3. Choose a different year, e.g. 2020, and press “OK”.
  4. Date is still 2019-04-07.
  5. Choose a different month, e.g. 05, and press “OK”.
  6. Date is still 2019-04-07.

Expected result

It should be possible to change …

  1. the month without having to choose the day again.
  2. the year without having to choose the month (and the day) again.

Actual result

The changes are ignored unless day or month and day are chosen.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I added a prop partial-update implement this feature in ^3.0.2. https://codesandbox.io/s/partial-update-kc4k1?fontsize=14&hidenavigation=1&theme=dark

    handleSelectYear(year) {
      let value = this.$refs.datepicker.currentValue;
      if (value) {
        value = new Date(new Date(value).setFullYear(year));
        this.$refs.datepicker.selectDate(value);
      }
    },
    handleSelectMonth(month) {
      let value = this.$refs.datepicker.currentValue;
      if (value) {
        value = new Date(new Date(value).setMonth(month));
        this.$refs.datepicker.selectDate(value);
      }
    }

If you need to confirm the select-year https://codesandbox.io/s/vvz89oqno3