-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Room list: add sections to shared components #32735
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8deece4
feat: add section header
florianduros b3f4691
refactor: remove index and role related to list box from RoomListItem…
florianduros b95c5a6
feat: add wrapper to RoomListItemView to handle different accessiblit…
florianduros 739d5cb
feat: add section support to VirtualizedRoomListView
florianduros bc25de4
feat: add sections support to RoomListView
florianduros 65332b2
test: add screenshot for sections header
florianduros 874d3e9
test: add/update screenshots for sections
florianduros 4d28989
feat: force flat list on view model
florianduros e4856f6
test: update RoomListViewModel test
florianduros 25a342d
test: fix breaking test
florianduros ea6c1b6
chore: rename `getSectionViewModel` to `getSectionHeaderViewModel`
florianduros 0c81d04
chore: add missing `RoomListItemAccessibilityWrapper` export
florianduros b9632ec
chore: merge `react` imports
florianduros bc93425
chore: simplify and add comment to `getItemKey` and `getHeaderKey`
florianduros bae1f92
chore add comments to `getItemComponent` variants
florianduros 10cb463
chore: fix typo in example doc
florianduros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Binary file added
BIN
+8.65 KB
...sibilityWrapper/RoomListItemAccessibilityWrapper.stories.tsx/flat-list-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.65 KB
...ssibilityWrapper/RoomListItemAccessibilityWrapper.stories.tsx/sections-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.92 KB
...mListSectionHeaderView/RoomListSectionHeaderView.stories.tsx/collapsed-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.93 KB
...oomListSectionHeaderView/RoomListSectionHeaderView.stories.tsx/default-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.93 KB
...stSectionHeaderView/RoomListSectionHeaderView.stories.tsx/first-header-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.92 KB
...HeaderView/RoomListSectionHeaderView.stories.tsx/last-header-collapsed-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.59 KB
...ListSectionHeaderView/RoomListSectionHeaderView.stories.tsx/long-title-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.4 KB
...ines__/room-list/RoomListView/RoomListView.stories.tsx/large-flat-list-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-59.4 KB
...baselines__/room-list/RoomListView/RoomListView.stories.tsx/large-list-auto.png
Binary file not shown.
Binary file added
BIN
+37.6 KB
...s__/room-list/RoomListView/RoomListView.stories.tsx/large-section-list-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.6 KB
.../__baselines__/room-list/RoomListView/RoomListView.stories.tsx/section-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14 KB
...ines__/room-list/RoomListView/RoomListView.stories.tsx/small-flat-list-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-39.8 KB
...baselines__/room-list/RoomListView/RoomListView.stories.tsx/small-list-auto.png
Binary file not shown.
Binary file added
BIN
+16.2 KB
...s__/room-list/RoomListView/RoomListView.stories.tsx/small-section-list-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+22.5 KB
...t/VirtualizedRoomListView/VirtualizedRoomListView.stories.tsx/sections-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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
67 changes: 67 additions & 0 deletions
67
...c/room-list/RoomListItemAccessibilityWrapper/RoomListItemAccessibilityWrapper.stories.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Copyright 2026 Element Creations Ltd. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| * Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| import React from "react"; | ||
| import { fn } from "storybook/test"; | ||
|
|
||
| import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
| import { RoomListItemAccessibilityWrapper } from "./RoomListItemAccessibilityWrapper"; | ||
| import { createMockRoomItemViewModel, renderAvatar } from "../story-mocks"; | ||
|
|
||
| const meta = { | ||
| title: "Room List/RoomListItemAccessibiltyWrapper", | ||
| component: RoomListItemAccessibilityWrapper, | ||
| tags: ["autodocs"], | ||
| args: { | ||
| roomIndex: 0, | ||
| roomIndexInSection: 0, | ||
| roomCount: 10, | ||
| onFocus: fn(), | ||
| isFirstItem: false, | ||
| isLastItem: false, | ||
| renderAvatar, | ||
| isSelected: false, | ||
| isFocused: false, | ||
| vm: createMockRoomItemViewModel("!room:server", "Room name", 0), | ||
| }, | ||
| decorators: [ | ||
| (Story) => ( | ||
| <div style={{ width: "320px", padding: "8px" }}> | ||
| <Story /> | ||
| </div> | ||
| ), | ||
| ], | ||
| } satisfies Meta<typeof RoomListItemAccessibilityWrapper>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const FlatList: Story = { | ||
| args: { | ||
| isInFlatList: true, | ||
| }, | ||
| decorators: [ | ||
| (Story) => ( | ||
| <div role="listbox" aria-label="Room list"> | ||
|
Check warning on line 49 in packages/shared-components/src/room-list/RoomListItemAccessibilityWrapper/RoomListItemAccessibilityWrapper.stories.tsx
|
||
| <Story /> | ||
| </div> | ||
| ), | ||
| ], | ||
| }; | ||
|
|
||
| export const Sections: Story = { | ||
| args: { | ||
| isInFlatList: false, | ||
| }, | ||
| decorators: [ | ||
| (Story) => ( | ||
| <div role="treegrid" aria-label="Room list" aria-rowcount={10}> | ||
| <Story /> | ||
| </div> | ||
| ), | ||
| ], | ||
| }; | ||
51 changes: 51 additions & 0 deletions
51
...nents/src/room-list/RoomListItemAccessibilityWrapper/RoomListItemAccessibilityWrapper.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Copyright 2026 Element Creations Ltd. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| * Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| import React, { memo, type JSX } from "react"; | ||
|
|
||
| import { RoomListItemView, type RoomListItemViewProps } from "../RoomListItemView"; | ||
| import { getItemAccessibleProps } from "../../utils/VirtualizedList"; | ||
|
|
||
| export interface RoomListItemAccessibilityWrapperPros extends RoomListItemViewProps { | ||
| /** Index of this room in the list */ | ||
| roomIndex: number; | ||
| /** Index of this room in its section */ | ||
| roomIndexInSection: number; | ||
| /** Total number of rooms in the list */ | ||
| roomCount: number; | ||
| /** Whether the room list is displayed as a flat list */ | ||
| isInFlatList: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Wrapper around RoomListItemView that adds accessibility props based on the room's position in the list and whether the list is flat or grouped. | ||
| * In a flat list, each item gets listbox item props. In a grouped list, each item gets treegrid cell props. | ||
| * | ||
| * @example | ||
| * `` | ||
| * <RoomListItemAccessibilityWrapper | ||
| * roomIndex={0} | ||
| * roomIndexInSection={0} | ||
| * roomCount={10} | ||
| * isInFlatList={true} | ||
| * {...otherRoomListItemViewProps} | ||
| * /> | ||
| * ``` | ||
| */ | ||
| export const RoomListItemAccessibilityWrapper = memo(function RoomListItemAccessibilityWrapper({ | ||
| roomIndex, | ||
| roomCount, | ||
| roomIndexInSection, | ||
| isInFlatList, | ||
| ...rest | ||
| }: RoomListItemAccessibilityWrapperPros): JSX.Element { | ||
| const itemA11yProps = isInFlatList ? getItemAccessibleProps("listbox", roomIndex, roomCount) : { role: "gridcell" }; | ||
| const item = <RoomListItemView {...rest} {...itemA11yProps} />; | ||
|
|
||
| if (isInFlatList) return item; | ||
| return <div {...getItemAccessibleProps("treegrid", roomIndex, roomIndexInSection)}>{item}</div>; | ||
| }); |
8 changes: 8 additions & 0 deletions
8
packages/shared-components/src/room-list/RoomListItemAccessibilityWrapper/index.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /* | ||
| * Copyright 2026 Element Creations Ltd. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| * Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| export { RoomListItemAccessibilityWrapper } from "./RoomListItemAccessibilityWrapper"; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Export
RoomListItemAccessiblityWrappertooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 0c81d04