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(input-date-picker, date-picker): ensure day selection doesn't activate the previous day in certain scenarios #9424

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
facaff2
fix(input-date-picker): selecting day no longer activates previous day
eriklharper May 24, 2024
72e891e
adding zero padding to month and day values less than 10
eriklharper May 24, 2024
734e2a9
Merge branch 'main' of github.com:Esri/calcite-design-system into eri…
eriklharper May 28, 2024
b55832a
padStarting the year as well
eriklharper May 28, 2024
6c978ef
adding test emulating CEST timezone
eriklharper May 29, 2024
eb3c9d4
adding more comprehensive tests, updating dateToISO docs
eriklharper Jun 4, 2024
4adba33
adding input-date-picker tests
eriklharper Jun 5, 2024
7823feb
Merge branch 'main' into eriklharper/9422-previous-day-selected-input…
eriklharper Jun 6, 2024
6f571bb
Merge branch 'main' into eriklharper/9422-previous-day-selected-input…
eriklharper Jun 6, 2024
fec70bd
Merge branch 'main' into eriklharper/9422-previous-day-selected-input…
eriklharper Jun 6, 2024
71c9ede
grouping tests into a describe block
eriklharper Jun 7, 2024
e6c7b04
Merge branch 'eriklharper/9422-previous-day-selected-input-date-picke…
eriklharper Jun 7, 2024
dce8d4f
DRYing up the century tests
eriklharper Jun 7, 2024
905f766
Merge branch 'main' into eriklharper/9422-previous-day-selected-input…
eriklharper Jun 7, 2024
795e6f7
Merge branch 'main' into eriklharper/9422-previous-day-selected-input…
eriklharper Jun 7, 2024
32f47ad
skipping problematic test to see if CI passes
eriklharper Jun 7, 2024
4e4820a
Merge branch 'main' of github.com:Esri/calcite-design-system into eri…
eriklharper Jun 10, 2024
3d9e5c2
missing awaits
eriklharper Jun 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,22 @@ describe("calcite-date-picker", () => {
await page.waitForChanges();
expect(await datePicker.getProperty("value")).toEqual(["2020-09-15", "2020-09-30"]);
});

it("doesn't select the previous day in CEST timezone", async () => {
const page = await newE2EPage();
await page.emulateTimezone("Europe/Zurich");

await page.setContent(html` <calcite-date-picker value="1850-03-12"></calcite-date-picker> `);

const datePicker = await page.find("calcite-date-picker");

expect(await datePicker.getProperty("value")).toBe("1850-03-12");

await selectDay("18500307", page, "mouse");
await page.waitForChanges();

expect(await datePicker.getProperty("value")).toBe("1850-03-07");
});
});

async function setActiveDate(page: E2EPage, date: string): Promise<void> {
Expand Down
5 changes: 4 additions & 1 deletion packages/calcite-components/src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ export function datePartsFromLocalizedString(
*/
export function dateToISO(date?: Date): string {
if (date instanceof Date) {
return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toISOString().split("T")[0];
jcfranco marked this conversation as resolved.
Show resolved Hide resolved
const month = String(date.getMonth() + 1).padStart(2, "0");
eriklharper marked this conversation as resolved.
Show resolved Hide resolved
const day = String(date.getDate()).padStart(2, "0");
const year = String(date.getFullYear()).padStart(4, "0");
return `${year}-${month}-${day}`;
}
return "";
}
Expand Down
Loading