-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New room list: filter list can be collapsed #29992
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
Open
florianduros
wants to merge
11
commits into
develop
Choose a base branch
from
florianduros/new-room-list/merge-filters
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
70ad8a1
feat: add new hook to check if a node is visible
florianduros 15a4637
feat: filters in new room list can be collapsed
florianduros def54b8
feat: add animation to filter list
florianduros d354977
feat: hide chevron when list fit on one line
florianduros 135a75f
fix: use correct label for expand button
florianduros 6200a7d
test: update room list panel snapshots
florianduros 5f7fb62
test: add tests for useIsNodeVisible
florianduros 40df1b1
chore: update i18n
florianduros 892053e
test: add tests for primary filters
florianduros 86a0ea3
test(e2e): update existing screenshots
florianduros f3674ce
test(e2e): update primary filter 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
Binary file modified
BIN
-2.65 KB
(90%)
...m-list-panel/room-list-filter-sort.spec.ts/room-panel-empty-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 modified
BIN
-2.71 KB
(61%)
.../room-list-panel/room-list-filter-sort.spec.ts/unread-primary-filters-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 modified
BIN
-2.67 KB
(57%)
...m-list-panel/room-list-filter-sort.spec.ts/unselected-primary-filters-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 modified
BIN
+26 Bytes
(100%)
.../room-list-panel/room-list-header.spec.ts/room-list-header-space-menu-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 modified
BIN
-1.74 KB
(94%)
...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 modified
BIN
-3.2 KB
(82%)
...l/room-list-panel/room-list-panel.spec.ts/room-list-panel-smallscreen-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 modified
BIN
-1.38 KB
(98%)
...el/room-list-panel/room-list.spec.ts/room-list-item-open-more-options-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 modified
BIN
-1.45 KB
(98%)
...list-panel/room-list.spec.ts/room-list-item-open-notification-options-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 modified
BIN
-2.2 KB
(98%)
.../room-list.spec.ts/room-list-item-open-notification-options-selection-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 modified
BIN
+1.13 KB
(110%)
...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 modified
BIN
+846 Bytes
(100%)
...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
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,61 @@ | ||
/* | ||
* Copyright 2025 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import { useCallback, useEffect, useState, type RefCallback } from "react"; | ||
|
||
/** | ||
* A hook to check if a node is visible in the viewport. | ||
* This hook uses the Intersection Observer API to observe the visibility of a node. | ||
* Both {@link rootRef} and {@link nodeRef} can be changed at any time, the hook will re-observe the node. | ||
* | ||
* @param options - see {@link IntersectionObserverInit} for more details. Root argument is omitted, see {@link rootRef} instead. | ||
*/ | ||
export function useIsNodeVisible<T extends HTMLElement, J extends HTMLElement>( | ||
options?: Omit<IntersectionObserverInit, "root">, | ||
): { | ||
/** | ||
* Whether the node is visible in the viewport. `null` if the node the root ref are not set. | ||
*/ | ||
isVisible: boolean | null; | ||
/** | ||
* A ref to the node to be observed. | ||
*/ | ||
nodeRef: RefCallback<T>; | ||
/** | ||
* A ref to be used as the root for the Intersection Observer. See {@link IntersectionObserverInit.root} for more details. | ||
*/ | ||
rootRef: RefCallback<J>; | ||
} { | ||
const [isVisible, setIsVisible] = useState<boolean | null>(null); | ||
|
||
// We use ref callback and a state because using only a ref would not trigger a re-render if the node or the root changes | ||
const [watchedNode, setWatchedNode] = useState<T | null>(null); | ||
const nodeRef = useCallback((node: T | null) => setWatchedNode(node), []); | ||
|
||
const [rootNode, setRootNode] = useState<J | null>(null); | ||
const rootRef = useCallback((node: J | null) => setRootNode(node), []); | ||
|
||
useEffect(() => { | ||
// If the node or the root is not set, we don't need to observe anything | ||
if (!watchedNode || !rootNode) { | ||
setIsVisible(null); | ||
return; | ||
} | ||
|
||
const observer = new IntersectionObserver(([entry]) => setIsVisible(entry.isIntersecting), { | ||
root: rootNode, | ||
...options, | ||
}); | ||
|
||
observer.observe(watchedNode); | ||
return () => { | ||
observer.disconnect(); | ||
}; | ||
}, [watchedNode, rootNode, options]); | ||
|
||
return { isVisible, nodeRef, rootRef }; | ||
} |
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.