Skip to content

Commit

Permalink
fix(datepicker): disable next month button if max is reached
Browse files Browse the repository at this point in the history
  • Loading branch information
mladenplaninicic committed Nov 23, 2022
1 parent d0e726b commit 86bd195
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
isWithinInterval,
isSameWeek,
isSameMonth,
lastDayOfMonth,
} from 'date-fns'
import { debounceEvent, findItemLabel } from '../../../utils/helpers'
import { inheritAttributes } from '../../../utils/attributes'
Expand Down Expand Up @@ -903,7 +904,7 @@ export class Datepicker implements ComponentInterface, BalConfigObserver, FormIn
if (this.max) {
const maxDate = parse(this.max) as Date
const beforeDate = new Date(this.calcNextMonth().year, this.calcNextMonth().month, 1)
return isAfter(beforeDate, addDays(maxDate, 1))
return isAfter(beforeDate, lastDayOfMonth(maxDate) ? maxDate : addDays(maxDate, 1))
}
return false
}
Expand Down

0 comments on commit 86bd195

Please sign in to comment.