Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datetime): confirm method now uses selected date #24827

Merged
merged 5 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
6 changes: 3 additions & 3 deletions core/src/components/datetime/datetime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ export class Datetime implements ComponentInterface {
* the date that is currently selected, otherwise
* there can be 1 hr difference when dealing w/ DST
*/
const date = new Date(convertDataToISO(this.workingParts));
this.workingParts.tzOffset = date.getTimezoneOffset() * -1;
const date = new Date(convertDataToISO(this.activeParts));
this.activeParts.tzOffset = date.getTimezoneOffset() * -1;

this.value = convertDataToISO(this.workingParts);
this.value = convertDataToISO(this.activeParts);

if (closeOverlay) {
this.closeParentOverlay();
Expand Down
26 changes: 26 additions & 0 deletions core/src/components/datetime/test/basic/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,29 @@ test('datetime:rtl: basic', async () => {
const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot();
});


describe('datetime: confirm date', () => {

test('should set the date value based on the selected date', async () => {

const page = await newE2EPage({
html: `<ion-datetime value="2021-12-25T12:40:00.000Z"></ion-datetime>`
});

const buttons = await page.findAll('ion-datetime >>> .calendar-next-prev ion-button');

await buttons[1].click();

await page.waitForTimeout(350);

await page.$eval('ion-datetime', async (el: any) => {
await el.confirm();
});

const value = await (await page.find('ion-datetime')).getProperty('value');

expect(value).toMatch('2021-12-25T12:40:00');
});

});