From e86256f84501a919725d8098bc0b37be5eac15ac Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Fri, 7 Mar 2025 11:48:24 +0100 Subject: [PATCH] fix(room list): move aria-setsize and aria-posinset on room list cell --- .../views/rooms/RoomListPanel/RoomList.tsx | 12 +++++++---- .../rooms/RoomListPanel/RoomList-test.tsx | 2 -- .../__snapshots__/RoomList-test.tsx.snap | 21 ++++++++++++++++++- .../__snapshots__/RoomListPanel-test.tsx.snap | 2 -- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/components/views/rooms/RoomListPanel/RoomList.tsx b/src/components/views/rooms/RoomListPanel/RoomList.tsx index 4b51dcbaa4..c1f8bcdacb 100644 --- a/src/components/views/rooms/RoomListPanel/RoomList.tsx +++ b/src/components/views/rooms/RoomListPanel/RoomList.tsx @@ -26,7 +26,14 @@ interface RoomListProps { export function RoomList({ vm: { rooms, openRoom } }: RoomListProps): JSX.Element { const roomRendererMemoized = useCallback( ({ key, index, style }: ListRowProps) => ( - openRoom(rooms[index].roomId)} /> + openRoom(rooms[index].roomId)} + /> ), [rooms, openRoom], ); @@ -73,9 +80,6 @@ function useAccessibleList(rooms: Room[]): RefObject { const list = ref.current?.querySelector('[role="listbox"]'); if (!list) return; - // The list is virtualized so the number of items in the dom is not the same as the number of rooms - list.setAttribute("aria-setsize", `${rooms.length}`); - // Determine if a node is a row node const isRowNode = (node: HTMLElement): boolean => node.getAttribute("role") === "row"; diff --git a/test/unit-tests/components/views/rooms/RoomListPanel/RoomList-test.tsx b/test/unit-tests/components/views/rooms/RoomListPanel/RoomList-test.tsx index 2eee4ca3d9..9548a482ec 100644 --- a/test/unit-tests/components/views/rooms/RoomListPanel/RoomList-test.tsx +++ b/test/unit-tests/components/views/rooms/RoomListPanel/RoomList-test.tsx @@ -44,8 +44,6 @@ describe("", () => { it("should render a room list", async () => { const { asFragment } = await renderList(); expect(asFragment()).toMatchSnapshot(); - - expect(screen.getByRole("listbox").getAttribute("aria-setsize")).toBe(`${vm.rooms.length}`); }); it("should open the room", async () => { diff --git a/test/unit-tests/components/views/rooms/RoomListPanel/__snapshots__/RoomList-test.tsx.snap b/test/unit-tests/components/views/rooms/RoomListPanel/__snapshots__/RoomList-test.tsx.snap index 2ee00057e7..00848ec4dc 100644 --- a/test/unit-tests/components/views/rooms/RoomListPanel/__snapshots__/RoomList-test.tsx.snap +++ b/test/unit-tests/components/views/rooms/RoomListPanel/__snapshots__/RoomList-test.tsx.snap @@ -12,7 +12,6 @@ exports[` should render a room list 1`] = `
should render a room list 1`] = ` >