-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(date-picker): improve date-picker a11y (#6715)
**Related Issue:** #5570 ## Summary This improves `calcite-date-picker` a11y by: * moving `gridcell` role to `calcite-date-picker-month` component rendering (day wrapper) * adding `button` role to `calcite-date-picker-day` * providing a locale-aware `aria-label` to `calcite-date-picker-day` describing the associated day
- Loading branch information
Showing
7 changed files
with
117 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
import { disabled } from "../../tests/commonTests"; | ||
import { newProgrammaticE2EPage } from "../../tests/utils"; | ||
import { DATE_PICKER_FORMAT_OPTIONS } from "../date-picker/resources"; | ||
import { Serializable } from "puppeteer"; | ||
|
||
describe("calcite-date-picker-day", () => { | ||
it("can be disabled", async () => { | ||
const page = await newProgrammaticE2EPage(); | ||
await page.evaluate(() => { | ||
const dateEl = document.createElement("calcite-date-picker-day") as HTMLCalciteDatePickerDayElement; | ||
dateEl.active = true; | ||
dateEl.dateTimeFormat = new Intl.DateTimeFormat("en"); // options not needed as this is only needed for rendering | ||
dateEl.day = 3; | ||
document.body.append(dateEl); | ||
}); | ||
await page.waitForChanges(); | ||
|
||
return disabled({ tag: "calcite-date-picker-day", page }); | ||
}); | ||
|
||
describe("accessibility", () => { | ||
it("labels its associated day", async () => { | ||
const page = await newProgrammaticE2EPage(); | ||
await page.evaluate((dateTimeFormatOptions: Intl.DateTimeFormatOptions) => { | ||
const dateEl = document.createElement("calcite-date-picker-day") as HTMLCalciteDatePickerDayElement; | ||
dateEl.dateTimeFormat = new Intl.DateTimeFormat("en", dateTimeFormatOptions); | ||
dateEl.day = 20; | ||
dateEl.value = new Date("2020-02-20T08:00:00.000Z"); | ||
document.body.append(dateEl); | ||
}, DATE_PICKER_FORMAT_OPTIONS as Serializable); | ||
await page.waitForChanges(); | ||
const day = await page.find(`calcite-date-picker-day`); | ||
|
||
expect(day.getAttribute("aria-label")).toBe("Thursday, February 20, 2020"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const HEADING_LEVEL = 2; | ||
|
||
export const DATE_PICKER_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = { dateStyle: "full" }; |