From a3254ae76f54690ac965380d080a439bfeaea6f6 Mon Sep 17 00:00:00 2001 From: Chen Fengyuan Date: Sun, 6 Jan 2019 10:36:31 +0800 Subject: [PATCH] fix: fix unexpect month changing Fixes #195 --- CHANGELOG.md | 1 + src/js/handlers.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b33f692..787c861 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## next +- Fix wrong future month selection when today is 31 (#195). - Fix month picking issue when the format only contains `YYYY` and `MM` (#193). ## 1.0.3 (Dec 20, 2018) diff --git a/src/js/handlers.js b/src/js/handlers.js index cf72cbd..380bd5f 100644 --- a/src/js/handlers.js +++ b/src/js/handlers.js @@ -94,8 +94,8 @@ export default { } viewDate.setFullYear(viewYear); - viewDate.setMonth(viewMonth); viewDate.setDate(getMinDay(viewYear, viewMonth, viewDay)); + viewDate.setMonth(viewMonth); this.renderDays(); break; @@ -122,11 +122,13 @@ export default { case 'month': viewMonth = $.inArray($target.text(), options.monthsShort); date.setFullYear(viewYear); - date.setMonth(viewMonth); + + // Set date before month to avoid month changing (#195) date.setDate(getMinDay(viewYear, viewMonth, viewDay)); + date.setMonth(viewMonth); viewDate.setFullYear(viewYear); - viewDate.setMonth(viewMonth); viewDate.setDate(getMinDay(viewYear, viewMonth, viewDay)); + viewDate.setMonth(viewMonth); if (format.hasDay) { this.showView(VIEWS.DAYS);