mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 13:14:58 +08:00
fix sticky headers when results num get displayed
This commit is contained in:
parent
1751b4ba43
commit
7303166924
@ -62,7 +62,7 @@ limitations under the License.
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
height: 32px; // to match the header container
|
height: 32px; // to match the header container
|
||||||
// width set by JS
|
// width set by JS
|
||||||
width: calc(100% - 22px);
|
width: calc(100% - 15px);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't have a top style because the top is dependent on the room list header's
|
// We don't have a top style because the top is dependent on the room list header's
|
||||||
|
@ -110,6 +110,11 @@ export default class LeftPanel extends React.Component<IProps, IState> {
|
|||||||
dis.fire(Action.ViewRoomDirectory);
|
dis.fire(Action.ViewRoomDirectory);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private refreshStickyHeaders = () => {
|
||||||
|
if (!this.listContainerRef.current) return; // ignore: no headers to sticky
|
||||||
|
this.handleStickyHeaders(this.listContainerRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
private onBreadcrumbsUpdate = () => {
|
private onBreadcrumbsUpdate = () => {
|
||||||
const newVal = BreadcrumbsStore.instance.visible;
|
const newVal = BreadcrumbsStore.instance.visible;
|
||||||
if (newVal !== this.state.showBreadcrumbs) {
|
if (newVal !== this.state.showBreadcrumbs) {
|
||||||
@ -243,18 +248,10 @@ export default class LeftPanel extends React.Component<IProps, IState> {
|
|||||||
if (!header.classList.contains("mx_RoomSublist_headerContainer_sticky")) {
|
if (!header.classList.contains("mx_RoomSublist_headerContainer_sticky")) {
|
||||||
header.classList.add("mx_RoomSublist_headerContainer_sticky");
|
header.classList.add("mx_RoomSublist_headerContainer_sticky");
|
||||||
}
|
}
|
||||||
|
|
||||||
const newWidth = `${headerStickyWidth}px`;
|
|
||||||
if (header.style.width !== newWidth) {
|
|
||||||
header.style.width = newWidth;
|
|
||||||
}
|
|
||||||
} else if (!style.stickyTop && !style.stickyBottom) {
|
} else if (!style.stickyTop && !style.stickyBottom) {
|
||||||
if (header.classList.contains("mx_RoomSublist_headerContainer_sticky")) {
|
if (header.classList.contains("mx_RoomSublist_headerContainer_sticky")) {
|
||||||
header.classList.remove("mx_RoomSublist_headerContainer_sticky");
|
header.classList.remove("mx_RoomSublist_headerContainer_sticky");
|
||||||
}
|
}
|
||||||
if (header.style.width) {
|
|
||||||
header.style.removeProperty('width');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +429,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
|
|||||||
{this.renderHeader()}
|
{this.renderHeader()}
|
||||||
{this.renderSearchExplore()}
|
{this.renderSearchExplore()}
|
||||||
{this.renderBreadcrumbs()}
|
{this.renderBreadcrumbs()}
|
||||||
<RoomListNumResults />
|
<RoomListNumResults onVisibilityChange={this.refreshStickyHeaders} />
|
||||||
<div className="mx_LeftPanel_roomListWrapper">
|
<div className="mx_LeftPanel_roomListWrapper">
|
||||||
<div
|
<div
|
||||||
className={roomListClasses}
|
className={roomListClasses}
|
||||||
|
@ -14,14 +14,18 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, {useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
|
|
||||||
import { _t } from "../../../languageHandler";
|
import { _t } from "../../../languageHandler";
|
||||||
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore";
|
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore";
|
||||||
import {useEventEmitter} from "../../../hooks/useEventEmitter";
|
import {useEventEmitter} from "../../../hooks/useEventEmitter";
|
||||||
import SpaceStore from "../../../stores/SpaceStore";
|
import SpaceStore from "../../../stores/SpaceStore";
|
||||||
|
|
||||||
const RoomListNumResults: React.FC = () => {
|
interface IProps {
|
||||||
|
onVisibilityChange?: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const RoomListNumResults: React.FC<IProps> = ({ onVisibilityChange }) => {
|
||||||
const [count, setCount] = useState<number>(null);
|
const [count, setCount] = useState<number>(null);
|
||||||
useEventEmitter(RoomListStore.instance, LISTS_UPDATE_EVENT, () => {
|
useEventEmitter(RoomListStore.instance, LISTS_UPDATE_EVENT, () => {
|
||||||
if (RoomListStore.instance.getFirstNameFilterCondition()) {
|
if (RoomListStore.instance.getFirstNameFilterCondition()) {
|
||||||
@ -32,6 +36,12 @@ const RoomListNumResults: React.FC = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (onVisibilityChange) {
|
||||||
|
onVisibilityChange();
|
||||||
|
}
|
||||||
|
}, [count, onVisibilityChange]);
|
||||||
|
|
||||||
if (typeof count !== "number") return null;
|
if (typeof count !== "number") return null;
|
||||||
|
|
||||||
return <div className="mx_LeftPanel_roomListFilterCount">
|
return <div className="mx_LeftPanel_roomListFilterCount">
|
||||||
|
Loading…
Reference in New Issue
Block a user