Skip to content

Commit ea6e793

Browse files
authored
fix(picker): Next decade button is disabled (sumcumo#52)
This fixes a bug where if you add, for example, the following prop: `:disabled-dates="{ from: new Date(2025, 6, 15) }"`, you are erroneously able to click the 'Next' button and reach a page for the '2030-39' decade (that only shows disabled years).
1 parent 78f331e commit ea6e793

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/components/PickerYear.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ export default {
5656
return false
5757
}
5858
const yearFrom = this.utils.getFullYear(this.disabledDates.from)
59-
const yearPageDate = this.utils.getFullYear(this.pageDate)
59+
const lastCellYear = this.years[this.years.length - 1].year
6060
61-
return Math.ceil(yearFrom / this.yearRange) * this.yearRange
62-
<= Math.ceil(yearPageDate / this.yearRange) * this.yearRange
61+
return yearFrom <= lastCellYear
6362
},
6463
/**
6564
* Checks if the previous decade is disabled or not

test/unit/specs/PickerYear/disabledYears.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('PickerYear', () => {
3838

3939
it('can\'t change decade when previous or next decades are disabled', () => {
4040
wrapper.setProps({
41-
pageDate: new Date(2016, 9, 15),
41+
pageDate: new Date(2010, 9, 1),
4242
disabledDates: {
4343
to: new Date(2010, 8, 6),
4444
from: new Date(2017, 10, 24),
@@ -50,7 +50,7 @@ describe('PickerYear', () => {
5050

5151
it('can change decade despite having a disabled decade', () => {
5252
wrapper.setProps({
53-
pageDate: new Date(2016, 9, 15),
53+
pageDate: new Date(2010, 9, 1),
5454
disabledDates: {
5555
to: new Date(2000, 11, 19),
5656
from: new Date(2021, 11, 19),

0 commit comments

Comments
 (0)