Skip to content

Commit

Permalink
a11y: improve screen reader and VoiceOver support (#2609)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl authored Nov 30, 2024
1 parent 37cc0ca commit 3d994aa
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 239 deletions.
2 changes: 1 addition & 1 deletion examples/FixedWeeks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ beforeEach(() => {
});

test("should render 7 rows", () => {
expect(screen.getAllByRole("row")).toHaveLength(7);
expect(screen.getAllByRole("row", { hidden: true })).toHaveLength(7);
});
2 changes: 1 addition & 1 deletion examples/Input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function textbox() {
}

function gridcells() {
return screen.queryAllByRole("cell") as HTMLTableCellElement[];
return screen.queryAllByRole("gridcell") as HTMLTableCellElement[];
}

function selectedCells() {
Expand Down
2 changes: 1 addition & 1 deletion examples/ModifiersHidden.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ afterAll(() => jest.useRealTimers());
test.each(days)("the day %s should be hidden", (day) => {
render(<ModifiersHidden />);
expect(
screen.queryByRole("cell", { name: `${day.getDate()}` })
screen.queryByRole("gridcell", { name: `${day.getDate()}` })
).not.toBeInTheDocument();
});
2 changes: 1 addition & 1 deletion examples/Range.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("when a day in the range is clicked", () => {
});

function getAllSelected() {
const gridcells = screen.getAllByRole("cell");
const gridcells = screen.getAllByRole("gridcell");

return Array.from(gridcells).filter(
(gridcell) => gridcell.getAttribute("aria-selected") === "true"
Expand Down
4 changes: 3 additions & 1 deletion examples/TestCase2511.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ beforeEach(async () => {
});

test("first weekday is Monday", () => {
const weekdaysElements = screen.queryAllByRole("columnheader");
const weekdaysElements = screen.queryAllByRole("columnheader", {
hidden: true
});
expect(weekdaysElements[0]).toHaveAccessibleName("Monday");
});
4 changes: 3 additions & 1 deletion examples/TestCase2585.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ import { TestCase2585 } from "./TestCase2585";
render(<TestCase2585 />);

test("should render 42*12 days", () => {
expect(screen.getAllByRole("cell")).toHaveLength(42 * 12);
expect(screen.getAllByRole("gridcell", { hidden: true })).toHaveLength(
42 * 12
);
});
6 changes: 5 additions & 1 deletion examples/WeeknumberCustom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ beforeEach(() => {
});

test("should display the 1st week (even if December)", () => {
expect(screen.getByRole("rowheader", { name: `W1` })).toBeInTheDocument();
expect(
screen.getByRole("rowheader", {
name: (name, el) => name === "W1"
})
).toBeInTheDocument();
});
Loading

0 comments on commit 3d994aa

Please sign in to comment.