-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New room list: basic flat list #29368
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
florianduros
merged 10 commits into
develop
from
florianduros/new-room-list/fist-step-list
Mar 6, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
54c50f7
chore: make the room list panel a flexbox
florianduros 45335e1
feat(new room list): add `RoomListCell` component
florianduros ab284cc
feat(new room list): add virtualized `RoomList` component
florianduros 2dd97a7
feat(new room list): add `RoomListView` component
florianduros 7f93fc4
feat(new room list): use `RoomListView` in `RoomListPanel`
florianduros 112fd59
test(new room list): add test for room cell
florianduros ca87557
test(new room list): update room list panel tests
florianduros 41b7060
test(new room list): add test to virtualized room list
florianduros be633e6
test(e2e): add room list tests
florianduros f0a78ec
test(e2e): update room panel tests
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
50 changes: 50 additions & 0 deletions
50
playwright/e2e/left-panel/room-list-panel/room-list.spec.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,50 @@ | ||
/* | ||
* Copyright 2025 New Vector 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 { type Page } from "@playwright/test"; | ||
|
||
import { test, expect } from "../../../element-web-test"; | ||
|
||
test.describe("Room list", () => { | ||
test.use({ | ||
labsFlags: ["feature_new_room_list"], | ||
}); | ||
|
||
/** | ||
* Get the room list | ||
* @param page | ||
*/ | ||
function getRoomList(page: Page) { | ||
return page.getByTestId("room-list"); | ||
} | ||
|
||
test.beforeEach(async ({ page, app, user }) => { | ||
// The notification toast is displayed above the search section | ||
await app.closeNotificationToast(); | ||
for (let i = 0; i < 30; i++) { | ||
await app.client.createRoom({ name: `room${i}` }); | ||
} | ||
}); | ||
|
||
test("should render the room list", { tag: "@screenshot" }, async ({ page, app, user }) => { | ||
const roomListView = getRoomList(page); | ||
await expect(roomListView.getByRole("gridcell", { name: "Open room room29" })).toBeVisible(); | ||
await expect(roomListView).toMatchScreenshot("room-list.png"); | ||
|
||
await roomListView.hover(); | ||
// Scroll to the end of the room list | ||
await page.mouse.wheel(0, 1000); | ||
await expect(roomListView.getByRole("gridcell", { name: "Open room room0" })).toBeVisible(); | ||
await expect(roomListView).toMatchScreenshot("room-list-scrolled.png"); | ||
}); | ||
|
||
test("should open the room when it is clicked", async ({ page, app, user }) => { | ||
const roomListView = getRoomList(page); | ||
await roomListView.getByRole("gridcell", { name: "Open room room29" }).click(); | ||
await expect(page.getByRole("heading", { name: "room29", level: 1 })).toBeVisible(); | ||
}); | ||
}); |
Binary file modified
BIN
+20.8 KB
(370%)
...ts/left-panel/room-list-panel/room-list-panel.spec.ts/room-list-panel-linux.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
+24.8 KB
...ight/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-linux.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.1 KB
...shots/left-panel/room-list-panel/room-list.spec.ts/room-list-scrolled-linux.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2025 New Vector 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. | ||
*/ | ||
|
||
.mx_RoomList { | ||
height: 100%; | ||
|
||
.mx_RoomList_List { | ||
/* Avoid when on hover, the background color to be on top of the right border */ | ||
padding-right: 1px; | ||
} | ||
} |
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,44 @@ | ||
/* | ||
* Copyright 2025 New Vector 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. | ||
*/ | ||
|
||
/** | ||
* The RoomCell has the following structure: | ||
* button----------------------------------------| | ||
* | <-12px-> container--------------------------| | ||
* | | room avatar <-12px-> content-----| | ||
* | | | room_name | | ||
* | | | ----------| <-- border | ||
* |---------------------------------------------| | ||
*/ | ||
.mx_RoomListCell { | ||
all: unset; | ||
|
||
&:hover { | ||
background-color: var(--cpd-color-bg-action-secondary-hovered); | ||
} | ||
|
||
.mx_RoomListCell_container { | ||
padding-left: var(--cpd-space-3x); | ||
font: var(--cpd-font-body-md-regular); | ||
height: 100%; | ||
|
||
.mx_RoomListCell_content { | ||
height: 100%; | ||
flex: 1; | ||
/* The border is only under the room name and the future hover menu */ | ||
border-bottom: var(--cpd-border-width-0-5) solid var(--cpd-color-bg-subtle-secondary); | ||
box-sizing: border-box; | ||
min-width: 0; | ||
|
||
span { | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
} | ||
} | ||
} |
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
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 2025 New Vector 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, { useCallback, type JSX } from "react"; | ||
import { AutoSizer, List, type ListRowProps } from "react-virtualized"; | ||
|
||
import { type RoomListViewState } from "../../../viewmodels/roomlist/RoomListViewModel"; | ||
import { _t } from "../../../../languageHandler"; | ||
import { RoomListCell } from "./RoomListCell"; | ||
|
||
interface RoomListProps { | ||
/** | ||
* The view model state for the room list. | ||
*/ | ||
vm: RoomListViewState; | ||
} | ||
|
||
/** | ||
* A virtualized list of rooms. | ||
*/ | ||
export function RoomList({ vm: { rooms, openRoom } }: RoomListProps): JSX.Element { | ||
const roomRendererMemoized = useCallback( | ||
({ key, index, style }: ListRowProps) => ( | ||
<RoomListCell room={rooms[index]} key={key} style={style} onClick={() => openRoom(rooms[index].roomId)} /> | ||
), | ||
[rooms, openRoom], | ||
); | ||
|
||
// The first div is needed to make the virtualized list take all the remaining space and scroll correctly | ||
return ( | ||
<div className="mx_RoomList" data-testid="room-list"> | ||
<AutoSizer> | ||
{({ height, width }) => ( | ||
<List | ||
aria-label={_t("room_list|list_title")} | ||
className="mx_RoomList_List" | ||
rowRenderer={roomRendererMemoized} | ||
rowCount={rooms.length} | ||
rowHeight={48} | ||
height={height} | ||
width={width} | ||
/> | ||
)} | ||
</AutoSizer> | ||
</div> | ||
); | ||
} |
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,44 @@ | ||
/* | ||
* Copyright 2025 New Vector 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, { type JSX } from "react"; | ||
import { type Room } from "matrix-js-sdk/src/matrix"; | ||
|
||
import { _t } from "../../../../languageHandler"; | ||
import { Flex } from "../../../utils/Flex"; | ||
import DecoratedRoomAvatar from "../../avatars/DecoratedRoomAvatar"; | ||
|
||
interface RoomListCellProps extends React.HTMLAttributes<HTMLButtonElement> { | ||
/** | ||
* The room to display | ||
*/ | ||
room: Room; | ||
} | ||
|
||
/** | ||
* A cell in the room list | ||
*/ | ||
export function RoomListCell({ room, ...props }: RoomListCellProps): JSX.Element { | ||
return ( | ||
<button | ||
className="mx_RoomListCell" | ||
type="button" | ||
aria-label={_t("room_list|room|open_room", { roomName: room.name })} | ||
{...props} | ||
> | ||
{/* We need this extra div between the button and the content in order to add a padding which is not messing with the virtualized list */} | ||
<Flex className="mx_RoomListCell_container" gap="var(--cpd-space-3x)" align="center"> | ||
<DecoratedRoomAvatar room={room} size="32px" /> | ||
<Flex className="mx_RoomListCell_content" align="center"> | ||
{/* We truncate the room name when too long. Title here is to show the full name on hover */} | ||
<span title={room.name}>{room.name}</span> | ||
{/* Future hover menu et notification badges */} | ||
</Flex> | ||
</Flex> | ||
</button> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2025 New Vector 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, { type JSX } from "react"; | ||
|
||
import { useRoomListViewModel } from "../../../viewmodels/roomlist/RoomListViewModel"; | ||
import { RoomList } from "./RoomList"; | ||
|
||
/** | ||
* Host the room list and the (future) room filters | ||
*/ | ||
export function RoomListView(): JSX.Element { | ||
const vm = useRoomListViewModel(); | ||
// Room filters will be added soon | ||
return <RoomList vm={vm} />; | ||
} |
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.
Would be nice if this component eventually had it's own vm.
Uh oh!
There was an error while loading. Please reload this page.
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.
Hmm, it can be introduced when adding the hover menu I think. In all cases, this component needs the room in props so it will be an empty vm here.
We can move the
Action.ViewRoom
dispatcher un when we will add this vm