Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/src/components/datetime/datetime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,9 @@ export class Datetime implements ComponentInterface {

connectedCallback() {
this.clearFocusVisible = startFocusVisible(this.el).destroy;
this.loadTimeout = setTimeout(() => {
this.ensureReadyIfVisible();
}, 100);
Comment thread
os-davidlourenco marked this conversation as resolved.
}

disconnectedCallback() {
Expand All @@ -1095,6 +1098,7 @@ export class Datetime implements ComponentInterface {
}
if (this.loadTimeout) {
clearTimeout(this.loadTimeout);
this.loadTimeout = undefined;
}
}

Expand Down
23 changes: 23 additions & 0 deletions core/src/components/datetime/test/basic/datetime.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,29 @@ configs().forEach(({ title, screenshot, config }) => {
const datetime = page.locator('ion-datetime');
await expect(datetime).toHaveScreenshot(screenshot(`datetime-footer-custom-buttons`));
});
test('should only have one active month option after changing month twice', async ({ page }) => {
Comment thread
os-davidlourenco marked this conversation as resolved.
Outdated
await page.setContent(
`
<ion-datetime value="2022-05-03"></ion-datetime>
`,
config
);

await page.locator('.datetime-ready').waitFor();

const nextMonthButton = page.locator('ion-datetime .calendar-next-prev ion-button').nth(1);
const monthYearButton = page.locator('ion-datetime .calendar-month-year');

await nextMonthButton.click();
await nextMonthButton.click();
await page.waitForChanges();
Comment thread
os-davidlourenco marked this conversation as resolved.
Outdated

await monthYearButton.click();
await page.waitForChanges();

const selectedMonthOptions = page.locator('.month-column ion-picker-column-option.option-active');
await expect(selectedMonthOptions).toHaveCount(1);
});
});
});

Expand Down
6 changes: 2 additions & 4 deletions core/src/components/picker-column/picker-column.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentInterface, EventEmitter } from '@stencil/core';
import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core';
import { doc } from '@utils/browser';
import { getElementRoot, raf } from '@utils/helpers';
import { raf } from '@utils/helpers';
import { hapticSelectionChanged, hapticSelectionEnd, hapticSelectionStart } from '@utils/native/haptic';
import { isPlatform } from '@utils/platform';
import { createColorClasses } from '@utils/theme';
Expand Down Expand Up @@ -122,9 +122,7 @@ export class PickerColumn implements ComponentInterface {
* Because this initial call to scrollActiveItemIntoView has to fire before
* the scroll listener is set up, we need to manage the active class manually.
*/
const oldActive = getElementRoot(el).querySelector<HTMLIonPickerColumnOptionElement>(
`.${PICKER_ITEM_ACTIVE_CLASS}`
);
const oldActive = el.querySelector<HTMLIonPickerColumnOptionElement>(`.${PICKER_ITEM_ACTIVE_CLASS}`);
if (oldActive) {
this.setPickerItemActiveState(oldActive, false);
}
Expand Down
Loading