From 28423272e3a4c8a30249046a9607d97ce815ecb5 Mon Sep 17 00:00:00 2001 From: Yiping Date: Thu, 26 Sep 2019 00:10:45 +0800 Subject: [PATCH 1/2] fix(vdatepicker): fix min date fix #9039 --- .../vuetify/src/components/VDatePicker/util/isDateAllowed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts b/packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts index 38c03dafa3e..465b42723e1 100644 --- a/packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts +++ b/packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts @@ -2,6 +2,6 @@ export type AllowedDateFunction = (date: string) => boolean export default function isDateAllowed (date: string, min: string, max: string, allowedFn: AllowedDateFunction | undefined) { return (!allowedFn || allowedFn(date)) && - (!min || date >= min) && + (!min || date >= min.substr(0, 10)) && (!max || date <= max) } From f1e1e9ce1bd37be4d918b4cea0f34c96172bba42 Mon Sep 17 00:00:00 2001 From: Yiping Date: Thu, 26 Sep 2019 15:17:05 +0800 Subject: [PATCH 2/2] test(vdatepicker): add test for min date with ISO format --- .../VDatePicker/__tests__/VDatePicker.date.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts b/packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts index ae9d5bdce3d..8aa336667f8 100644 --- a/packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts +++ b/packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts @@ -570,6 +570,20 @@ describe('VDatePicker.ts', () => { // eslint-disable-line max-statements expect(wrapper.html()).toMatchSnapshot() }) + it('should round down min date in ISO 8601 format', async () => { + const cb = jest.fn() + const wrapper = mountFunction({ + propsData: { + value: '2019-01-20', + min: '2019-01-06T15:55:56.441Z', + }, + }) + + wrapper.vm.$on('input', cb) + wrapper.findAll('.v-date-picker-table--date tbody tr+tr td:first-child button').at(0).trigger('click') + expect(cb.mock.calls[0][0]).toEqual('2019-01-06') + }) + it('should emit @input and not emit @change when month is clicked (not reative picker)', async () => { const wrapper = mountFunction({ propsData: {