From 858eb16794eaa1ca90b95f48fba156858152f094 Mon Sep 17 00:00:00 2001 From: "Anton Bagdatyev (Tonix)" Date: Sun, 26 Apr 2020 10:58:39 +0200 Subject: [PATCH 1/2] Fix for issue #325 (https://github.com/tempusdominus/bootstrap-4/issues/325) --- src/js/tempusdominus-bootstrap-4.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/tempusdominus-bootstrap-4.js b/src/js/tempusdominus-bootstrap-4.js index bce758e..c5d7225 100644 --- a/src/js/tempusdominus-bootstrap-4.js +++ b/src/js/tempusdominus-bootstrap-4.js @@ -359,7 +359,8 @@ const TempusDominusBootstrap4 = ($ => { // eslint-disable-line no-unused-vars } months.removeClass('active'); - if (this._getLastPickedDate().isSame(this._viewDate, 'y') && !this.unset) { + const lastPickedDate = this._getLastPickedDate(); + if (lastPickedDate && lastPickedDate.isSame(this._viewDate, 'y') && !this.unset) { months.eq(this._getLastPickedDate().month()).addClass('active'); } From 19fc2afcd23e37e3494a7a0c6b6786c3496086a4 Mon Sep 17 00:00:00 2001 From: "Anton Bagdatyev (Tonix)" Date: Mon, 27 Apr 2020 00:02:30 +0200 Subject: [PATCH 2/2] Fix for issue #325 - respecting ESLint one-var rule --- .prettierignore | 1 + src/js/tempusdominus-bootstrap-4.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..1d085ca --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +** diff --git a/src/js/tempusdominus-bootstrap-4.js b/src/js/tempusdominus-bootstrap-4.js index c5d7225..6ab4f4b 100644 --- a/src/js/tempusdominus-bootstrap-4.js +++ b/src/js/tempusdominus-bootstrap-4.js @@ -340,7 +340,8 @@ const TempusDominusBootstrap4 = ($ => { // eslint-disable-line no-unused-vars _updateMonths() { const monthsView = this.widget.find('.datepicker-months'), monthsViewHeader = monthsView.find('th'), - months = monthsView.find('tbody').find('span'), self = this; + months = monthsView.find('tbody').find('span'), self = this, + lastPickedDate = this._getLastPickedDate(); monthsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevYear); monthsViewHeader.eq(1).attr('title', this._options.tooltips.selectYear); @@ -359,7 +360,6 @@ const TempusDominusBootstrap4 = ($ => { // eslint-disable-line no-unused-vars } months.removeClass('active'); - const lastPickedDate = this._getLastPickedDate(); if (lastPickedDate && lastPickedDate.isSame(this._viewDate, 'y') && !this.unset) { months.eq(this._getLastPickedDate().month()).addClass('active'); }