-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New room list: add search section #29251
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 12 commits into
develop
from
florianduros/new-room-list/search-component
Feb 13, 2025
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4b8385e
feat(new room list): move `RoomListView` to its own folder and add st…
florianduros 7e3f992
feat(new room list): add search section
florianduros 0af7fb5
test(new room list): add tests for `RoomListSearch`
florianduros bfd7b69
test(new room list): add tests for `RoomListView`
florianduros 66d5fe1
test(e2e): add method to close notification toast to `ElementAppPage`
florianduros 3bcbfe4
test(e2e): add tests for the search section
florianduros 45f2f61
test(e2e): add tests for the room list view
florianduros f4d9aac
refactor: use Flex component
florianduros bb7563c
fix: loop icon size in search button
florianduros c2fdbf1
Merge branch 'develop' into florianduros/new-room-list/search-component
florianduros 6dc4f46
refactor: remove `focus_room_filter` listener
florianduros 3eac1de
Merge remote-tracking branch 'origin/florianduros/new-room-list/searc…
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
53 changes: 53 additions & 0 deletions
53
playwright/e2e/left-panel/room-list-view/room-list-search.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,53 @@ | ||
| /* | ||
| * 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("Search section of the room list", () => { | ||
| test.use({ | ||
| labsFlags: ["feature_new_room_list"], | ||
| }); | ||
|
|
||
| /** | ||
| * Get the search section of the room list | ||
| * @param page | ||
| */ | ||
| function getSearchSection(page: Page) { | ||
| return page.getByRole("search"); | ||
| } | ||
|
|
||
| test.beforeEach(async ({ page, app, user }) => { | ||
| // The notification toast is displayed above the search section | ||
| await app.closeNotificationToast(); | ||
| }); | ||
|
|
||
| test("should render the search section", { tag: "@screenshot" }, async ({ page, app, user }) => { | ||
| const searchSection = getSearchSection(page); | ||
| // exact=false to ignore the shortcut which is related to the OS | ||
| await expect(searchSection.getByRole("button", { name: "Search", exact: false })).toBeVisible(); | ||
| await expect(searchSection).toMatchScreenshot("search-section.png"); | ||
| }); | ||
|
|
||
| test("should open the spotlight when the search button is clicked", async ({ page, app, user }) => { | ||
| const searchSection = getSearchSection(page); | ||
| await searchSection.getByRole("button", { name: "Search", exact: false }).click(); | ||
| // The spotlight should be displayed | ||
| await expect(page.getByRole("dialog", { name: "Search Dialog" })).toBeVisible(); | ||
| }); | ||
|
|
||
| test("should open the room directory when the search button is clicked", async ({ page, app, user }) => { | ||
| const searchSection = getSearchSection(page); | ||
| await searchSection.getByRole("button", { name: "Explore rooms" }).click(); | ||
| const dialog = page.getByRole("dialog", { name: "Search Dialog" }); | ||
| // The room directory should be displayed | ||
| await expect(dialog).toBeVisible(); | ||
| // The public room filter should be displayed | ||
| await expect(dialog.getByText("Public rooms")).toBeVisible(); | ||
| }); | ||
| }); |
34 changes: 34 additions & 0 deletions
34
playwright/e2e/left-panel/room-list-view/room-list-view.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,34 @@ | ||
| /* | ||
| * 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("Search section of the room list", () => { | ||
| test.use({ | ||
| labsFlags: ["feature_new_room_list"], | ||
| }); | ||
|
|
||
| /** | ||
| * Get the room list view | ||
| * @param page | ||
| */ | ||
| function getRoomListView(page: Page) { | ||
| return page.getByTestId("room-list-view"); | ||
| } | ||
|
|
||
| test.beforeEach(async ({ page, app, user }) => { | ||
| // The notification toast is displayed above the search section | ||
| await app.closeNotificationToast(); | ||
| }); | ||
|
|
||
| test("should render the room list view", { tag: "@screenshot" }, async ({ page, app, user }) => { | ||
| const roomListView = getRoomListView(page); | ||
| await expect(roomListView).toMatchScreenshot("room-list-view.png"); | ||
| }); | ||
| }); |
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
+3.85 KB
...ots/left-panel/room-list-view/room-list-search.spec.ts/search-section-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
+6.21 KB
...shots/left-panel/room-list-view/room-list-view.spec.ts/room-list-view-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,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. | ||
| */ | ||
|
|
||
| .mx_RoomListSearch { | ||
| /* From figma, this should be aligned with the room header */ | ||
| height: 64px; | ||
| box-sizing: border-box; | ||
| border-bottom: 1px solid var(--cpd-color-bg-subtle-primary); | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--cpd-space-2x); | ||
| padding: 0 var(--cpd-space-3x); | ||
|
|
||
| svg { | ||
| fill: var(--cpd-color-icon-secondary); | ||
| } | ||
|
|
||
| .mx_RoomListSearch_search { | ||
| /* The search button should take all the remaining space */ | ||
| flex: 1; | ||
| font: var(--cpd-font-body-md-regular); | ||
| color: var(--cpd-color-text-secondary); | ||
|
|
||
| span { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| width: 100%; | ||
|
|
||
| kbd { | ||
| font-family: inherit; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .mx_RoomListSearch_explore:hover { | ||
| svg { | ||
| fill: var(--cpd-color-icon-primary); | ||
| } | ||
| } | ||
| } | ||
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,12 @@ | ||
| /* | ||
| * 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_RoomListView { | ||
| background-color: var(--cpd-color-bg-canvas-default); | ||
| height: 100%; | ||
| border-right: 1px solid var(--cpd-color-bg-subtle-primary); | ||
| } |
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 was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
src/components/views/rooms/RoomListView/RoomListSearch.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,79 @@ | ||
| /* | ||
| * 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, useCallback, useEffect } from "react"; | ||
| import { Button } from "@vector-im/compound-web"; | ||
| import ExploreIcon from "@vector-im/compound-design-tokens/assets/web/icons/explore"; | ||
| import SearchIcon from "@vector-im/compound-design-tokens/assets/web/icons/search"; | ||
|
|
||
| import { IS_MAC, Key } from "../../../../Keyboard"; | ||
| import { _t } from "../../../../languageHandler"; | ||
| import { ALTERNATE_KEY_NAME } from "../../../../accessibility/KeyboardShortcuts"; | ||
| import { shouldShowComponent } from "../../../../customisations/helpers/UIComponents"; | ||
| import { UIComponent } from "../../../../settings/UIFeature"; | ||
| import { MetaSpace } from "../../../../stores/spaces"; | ||
| import { Action } from "../../../../dispatcher/actions"; | ||
| import PosthogTrackers from "../../../../PosthogTrackers"; | ||
| import defaultDispatcher from "../../../../dispatcher/dispatcher"; | ||
|
|
||
| type RoomListSearchProps = { | ||
| /** | ||
| * Current active space | ||
| * The explore button is only displayed in the Home meta space | ||
| */ | ||
| activeSpace: string; | ||
| }; | ||
|
|
||
| /** | ||
| * A search component to be displayed at the top of the room list | ||
| * This component listen to the "focus_room_filter" action and opens the spotlight when fired. | ||
| * | ||
| * The `Explore` button is displayed only in the Home meta space and when UIComponent.ExploreRooms is enabled. | ||
| */ | ||
| export function RoomListSearch({ activeSpace }: RoomListSearchProps): JSX.Element { | ||
| const displayExploreButton = activeSpace === MetaSpace.Home && shouldShowComponent(UIComponent.ExploreRooms); | ||
|
|
||
| const openSpotlight = useCallback(() => defaultDispatcher.fire(Action.OpenSpotlight), []); | ||
| // Open the spotlight when the "focus_room_filter" action is dispatched | ||
| useEffect(() => { | ||
| const registerId = defaultDispatcher.register( | ||
| (payload) => payload.action === "focus_room_filter" && openSpotlight(), | ||
| ); | ||
| return () => defaultDispatcher.unregister(registerId); | ||
| }, [openSpotlight]); | ||
|
|
||
| return ( | ||
| <div className="mx_RoomListSearch" role="search"> | ||
| <Button | ||
| className="mx_RoomListSearch_search" | ||
| kind="secondary" | ||
| size="sm" | ||
| Icon={SearchIcon} | ||
| onClick={() => openSpotlight()} | ||
| > | ||
| <span> | ||
| {_t("action|search")} | ||
| <kbd>{IS_MAC ? "⌘ K" : _t(ALTERNATE_KEY_NAME[Key.CONTROL]) + " K"}</kbd> | ||
| </span> | ||
| </Button> | ||
| {displayExploreButton && ( | ||
| <Button | ||
| className="mx_RoomListSearch_explore" | ||
| kind="secondary" | ||
| size="sm" | ||
| Icon={ExploreIcon} | ||
| iconOnly={true} | ||
| aria-label={_t("action|explore_rooms")} | ||
| onClick={(ev) => { | ||
| defaultDispatcher.fire(Action.ViewRoomDirectory); | ||
| PosthogTrackers.trackInteraction("WebLeftPanelExploreRoomsButton", ev); | ||
| }} | ||
| /> | ||
| )} | ||
| </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,33 @@ | ||
| /* | ||
| 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 from "react"; | ||
|
|
||
| import { shouldShowComponent } from "../../../../customisations/helpers/UIComponents"; | ||
| import { UIComponent } from "../../../../settings/UIFeature"; | ||
| import { RoomListSearch } from "./RoomListSearch"; | ||
|
|
||
| type RoomListViewProps = { | ||
| /** | ||
| * Current active space | ||
| * See {@link RoomListSearch} | ||
| */ | ||
| activeSpace: string; | ||
| }; | ||
|
|
||
| /** | ||
| * A view component for the room list. | ||
| */ | ||
| export const RoomListView: React.FC<RoomListViewProps> = ({ activeSpace }) => { | ||
| const displayRoomSearch = shouldShowComponent(UIComponent.FilterContainer); | ||
|
|
||
| return ( | ||
| <div className="mx_RoomListView" data-testid="room-list-view"> | ||
| {displayRoomSearch && <RoomListSearch activeSpace={activeSpace} />} | ||
| </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,8 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| export { RoomListView } from "./RoomListView"; |
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.
can we not use our semantic
Flexcomponent instead?