From 939a162ad73c1fe49260941684c2e02c8d63b5c1 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Mon, 21 May 2018 08:24:56 +0200 Subject: [PATCH] Prevent selecting disabled dates --- src/components/date-picker/base/date-table.vue | 4 ++-- src/components/date-picker/base/mixin.js | 1 + src/components/date-picker/picker.vue | 10 +++++++++- src/styles/components/date-picker.less | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/date-picker/base/date-table.vue b/src/components/date-picker/base/date-table.vue index aa4822a..5f6e933 100644 --- a/src/components/date-picker/base/date-table.vue +++ b/src/components/date-picker/base/date-table.vue @@ -7,7 +7,7 @@ { + const sliceIndex = ['year', 'month', 'date'].indexOf((this.type)) + 1; + return [d.getFullYear(), d.getMonth(), d.getDate()].slice(0, sliceIndex).join('-'); + }; + const dateIsValid = panels.find(({cells}) => { + return cells.find(({date, disabled}) => compareDate(date) === compareDate(this.focusedDate) && !disabled); + }); + if (dateIsValid) this.onPick(this.focusedDate, false, 'date'); } } diff --git a/src/styles/components/date-picker.less b/src/styles/components/date-picker.less index 01a73ed..c9f768e 100644 --- a/src/styles/components/date-picker.less +++ b/src/styles/components/date-picker.less @@ -46,7 +46,7 @@ } &-cell:hover, &-focused{ em{ - background: @date-picker-cell-hover-bg; + background: @date-picker-cell-hover-bg !important; } } -- libgit2 0.21.4