Vuepic / vue-datepicker

Datepicker component for Vue 3
https://vue3datepicker.com
MIT License
1.48k stars 147 forks source link

`maxRange` not working with `month-picker` enabled #758

Closed AntonioDell closed 7 months ago

AntonioDell commented 8 months ago

Describe the bug When using month-picker together with maxRange the selection does not respect the set maxRange.

To Reproduce Stackblitz: https://stackblitz.com/edit/vuepic-vue-datepicker-prpkaq?file=src%2Fcomponents%2FPlayground.vue

Code:

<template>
  <div>
    <Datepicker v-model="date" :range="{ maxRange: 31 }" month-picker />
    {{ date }}
  </div>
</template>

<script setup>
import { ref } from 'vue';
import Datepicker from '@vuepic/vue-datepicker';
import '@vuepic/vue-datepicker/dist/main.css';

const date = ref();
</script>

Expected behavior The datepicker should disallow selecting months which are further apart then the maxRange specified. The calculation here is a bit ambiguous, a naive implementation would be to just calculate the days between the 1st of the starting month and the 1st of the ending month, but there is an argument to be made for 1st of starting month and last of ending month or even changing the intepretation of the maxRange parameter in month-picker mode, such that months are expected instead of days. Either is fine for me, it just needs to be documented.

Screenshots grafik

Desktop & mobile (please complete the following information):