Skip to content

Commit 57a21ad

Browse files
authored
fix(datetime): switching presentation closes month/year picker (#25667)
1 parent db28794 commit 57a21ad

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

core/src/components/datetime/datetime.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,13 @@ export class Datetime implements ComponentInterface {
10271027
this.destroyInteractionListeners();
10281028

10291029
this.initializeListeners();
1030+
1031+
/**
1032+
* The month/year picker from the date interface
1033+
* should be closed as it is not available in non-date
1034+
* interfaces.
1035+
*/
1036+
this.showMonthAndYear = false;
10301037
}
10311038

10321039
private processValue = (value?: string | null) => {

core/src/components/datetime/test/presentation/datetime.e2e.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ test.describe('datetime: presentation', () => {
8383

8484
expect(ionChangeSpy.length).toBe(1);
8585
});
86+
87+
test('switching presentation should close month/year picker', async ({ page }, testInfo) => {
88+
await test.skip(testInfo.project.metadata.rtl === true, 'This feature does not have RTL specific behaviors.');
89+
90+
await page.setContent(`
91+
<ion-datetime presentation="date"></ion-datetime>
92+
`);
93+
94+
await page.waitForSelector('.datetime-ready');
95+
96+
const datetime = page.locator('ion-datetime');
97+
const monthYearButton = page.locator('ion-datetime .calendar-month-year');
98+
await monthYearButton.click();
99+
100+
await expect(datetime).toHaveClass(/show-month-and-year/);
101+
102+
await datetime.evaluate((el: HTMLIonDatetimeElement) => (el.presentation = 'time'));
103+
await page.waitForChanges();
104+
105+
await expect(datetime).not.toHaveClass(/show-month-and-year/);
106+
});
86107
});
87108

88109
test.describe('datetime: presentation: time', () => {

0 commit comments

Comments
 (0)