mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(datetime): close month/year picker when hidden (#25789)
resolves #25787
This commit is contained in:
@@ -1086,6 +1086,15 @@ export class Datetime implements ComponentInterface {
|
||||
|
||||
this.destroyInteractionListeners();
|
||||
|
||||
/**
|
||||
* When datetime is hidden, we need to make sure that
|
||||
* the month/year picker is closed. Otherwise,
|
||||
* it will be open when the datetime re-appears
|
||||
* and the scroll area of the calendar grid will be 0.
|
||||
* As a result, the wrong month will be shown.
|
||||
*/
|
||||
this.showMonthAndYear = false;
|
||||
|
||||
writeTask(() => {
|
||||
this.el.classList.remove('datetime-ready');
|
||||
});
|
||||
|
||||
@@ -248,3 +248,34 @@ test.describe('datetime: swiping', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('datetime: visibility', () => {
|
||||
test('should reset month/year interface when hiding datetime', async ({ page, skip }) => {
|
||||
skip.rtl();
|
||||
skip.mode('md');
|
||||
|
||||
await page.setContent(`
|
||||
<ion-datetime></ion-datetime>
|
||||
`);
|
||||
|
||||
await page.waitForSelector('.datetime-ready');
|
||||
|
||||
const monthYearButton = page.locator('ion-datetime .calendar-month-year');
|
||||
const monthYearInterface = page.locator('ion-datetime .datetime-year');
|
||||
const datetime = page.locator('ion-datetime');
|
||||
|
||||
await monthYearButton.click();
|
||||
await page.waitForChanges();
|
||||
|
||||
await expect(monthYearInterface).toBeVisible();
|
||||
|
||||
await datetime.evaluate((el: HTMLIonDatetimeElement) => el.style.setProperty('display', 'none'));
|
||||
await expect(datetime).toBeHidden();
|
||||
|
||||
await datetime.evaluate((el: HTMLIonDatetimeElement) => el.style.removeProperty('display'));
|
||||
await expect(datetime).toBeVisible();
|
||||
|
||||
// month/year interface should be reset
|
||||
await expect(monthYearInterface).toBeHidden();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user