From 57a21adb38331ee5d74dacd1b0a2568f41a2d21e Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 26 Jul 2022 13:40:05 -0400 Subject: [PATCH] fix(datetime): switching presentation closes month/year picker (#25667) --- core/src/components/datetime/datetime.tsx | 7 +++++++ .../test/presentation/datetime.e2e.ts | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index 86b9b7ca4e..8008e4a8fe 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -1027,6 +1027,13 @@ export class Datetime implements ComponentInterface { this.destroyInteractionListeners(); this.initializeListeners(); + + /** + * The month/year picker from the date interface + * should be closed as it is not available in non-date + * interfaces. + */ + this.showMonthAndYear = false; } private processValue = (value?: string | null) => { diff --git a/core/src/components/datetime/test/presentation/datetime.e2e.ts b/core/src/components/datetime/test/presentation/datetime.e2e.ts index 8f254747c2..137c625fad 100644 --- a/core/src/components/datetime/test/presentation/datetime.e2e.ts +++ b/core/src/components/datetime/test/presentation/datetime.e2e.ts @@ -83,6 +83,27 @@ test.describe('datetime: presentation', () => { expect(ionChangeSpy.length).toBe(1); }); + + test('switching presentation should close month/year picker', async ({ page }, testInfo) => { + await test.skip(testInfo.project.metadata.rtl === true, 'This feature does not have RTL specific behaviors.'); + + await page.setContent(` + + `); + + await page.waitForSelector('.datetime-ready'); + + const datetime = page.locator('ion-datetime'); + const monthYearButton = page.locator('ion-datetime .calendar-month-year'); + await monthYearButton.click(); + + await expect(datetime).toHaveClass(/show-month-and-year/); + + await datetime.evaluate((el: HTMLIonDatetimeElement) => (el.presentation = 'time')); + await page.waitForChanges(); + + await expect(datetime).not.toHaveClass(/show-month-and-year/); + }); }); test.describe('datetime: presentation: time', () => {