-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Min/Max date ranges that disable arrows, hide invalid months/years. #628
Comments
Agree. The ability to disable or hide both future and past invalid dates would be a great addition. This is related to #380 ([Bug] When disabled-date is specified, we can still select Year and Month) |
any plans to implement this? it would be really nice to have this feature |
Hey, Any updates on this one? |
PR welcome! |
@mengxiong10 Hey I have created a PR for this issue. |
Hey, are there any news on the PR? |
@mengxiong10 , will the PR be merged any time soon? i would love to use this feature ;) |
@agnieszkabugla I'll add it in next week |
I add
<template>
<date-picker :disabled-date="disabledDate" :disabled-calendar-changer="disabledDate" />
</template>
<script>
export default {
methods: {
disabledDate(date) {
const today = new Date().setHours(0, 0, 0, 0)
return date < new Date(today);
},
},
};
</script>
<template>
<date-picker :disabled-date="disabledDate" :disabled-calendar-changer="disabledCalendarChanger" />
</template>
<script>
export default {
methods: {
disabledDate(date) {
const today = new Date().setHours(0, 0, 0, 0)
return date < new Date(today);
},
disabledCalendarChanger(date, type) {
// type: last-year , last-month, next-year, next-month, last-decade, next-decade, year, month
if (type === 'year' || type === 'month') {
return false
}
return this.disabledDate(date)
}
},
};
</script> |
This feature is good, but we found some quirks with the result. If dates are disabled in future, but the current value is long time in the past (in my example 2020-10-01) arrows do not work in neither direction and all dates in current month are disabled as well. I found two ways to resolve it finall:
I made a fiddle to explain it: While it may be logical, but a bit confusing for regular users and even for me ;). So maybe it could be possible to let the selector arrows work, but fast-forward to the closest suitable period? |
@mengxiong10 |
Any updates on this issue :)? |
The disabledDate API works great for discrete ranges of date, but it would be nice to be able to disable dates in such a way that next/previous arrows are also disabled, and to hide invalid months or years in the date picker that fall outside of the range.
For example: When entering birthdate, dates in the future may not be needed. When scheduling an appointment, dates in the past may not be needed.
Ideally, setting a maxDate to
new Date()
would:The text was updated successfully, but these errors were encountered: