From fab3fef541f1dca8b7ccad97679bf372af9539c0 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Wed, 9 Feb 2022 12:56:25 -0500 Subject: [PATCH 1/2] fix(datetime): navigate to month within min range --- core/src/components/datetime/datetime.tsx | 8 ++++---- core/src/components/datetime/test/minmax/e2e.ts | 14 ++++++++++++++ .../src/components/datetime/test/minmax/index.html | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index 42ed82a73b7..1c287aee949 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -720,8 +720,8 @@ export class Datetime implements ComponentInterface { const { month, year, day } = refMonthFn(this.workingParts); if (isMonthDisabled({ month, year, day: null }, { - minParts: this.minParts, - maxParts: this.maxParts + minParts: { ...this.minParts, day: null }, + maxParts: { ...this.maxParts, day: null } })) { return; } @@ -1238,8 +1238,8 @@ export class Datetime implements ComponentInterface { year, day: null }, { - minParts: this.minParts, - maxParts: this.maxParts + minParts: { ...this.minParts, day: null }, + maxParts: { ...this.maxParts, day: null } }); // The working month should never have swipe disabled. // Otherwise the CSS scroll snap will not work and the user diff --git a/core/src/components/datetime/test/minmax/e2e.ts b/core/src/components/datetime/test/minmax/e2e.ts index f040b65d66d..ae8a90595be 100644 --- a/core/src/components/datetime/test/minmax/e2e.ts +++ b/core/src/components/datetime/test/minmax/e2e.ts @@ -47,3 +47,17 @@ test('datetime: minmax navigation disabled', async () => { expect(navButtons[1]).toHaveAttribute('disabled'); }); + +test('datetime: min including day should not disable month', async () => { + const page = await newE2EPage({ + url: '/src/components/datetime/test/minmax?ionic:_testing=true' + }); + + const calendarMonths = await page.findAll('ion-datetime#min-with-day >>> .calendar-month'); + + await page.waitForChanges(); + + expect(calendarMonths[0]).toHaveClass('calendar-month-disabled'); + expect(calendarMonths[1]).not.toHaveClass('calendar-month-disabled'); + expect(calendarMonths[2]).not.toHaveClass('calendar-month-disabled'); +}) diff --git a/core/src/components/datetime/test/minmax/index.html b/core/src/components/datetime/test/minmax/index.html index 1f66778de15..848fc7cf3ce 100644 --- a/core/src/components/datetime/test/minmax/index.html +++ b/core/src/components/datetime/test/minmax/index.html @@ -62,6 +62,10 @@

h23 Min

locale: en-GB

+
+

Min with year/month/day

+ +
From 937206edf2c9b2d51e72759641eabaa9f099cf4a Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Wed, 9 Feb 2022 13:38:21 -0500 Subject: [PATCH 2/2] chore(): add comment for day: null purpose --- core/src/components/datetime/datetime.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index 1c287aee949..1f9ef3f15b1 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -1238,6 +1238,9 @@ export class Datetime implements ComponentInterface { year, day: null }, { + // The day is not used when checking if a month is disabled. + // Users should be able to access the min or max month, even if the + // min/max date is out of bounds (e.g. min is set to Feb 15, Feb should not be disabled). minParts: { ...this.minParts, day: null }, maxParts: { ...this.maxParts, day: null } });