Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Go to space landing page when clicking on a selected space #6442

Merged
merged 15 commits into from
May 17, 2022
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/components/views/spaces/SpaceTreeLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { SpaceKey } from "../../../stores/spaces";
import SpaceTreeLevelLayoutStore from "../../../stores/spaces/SpaceTreeLevelLayoutStore";
import NotificationBadge from "../rooms/NotificationBadge";
import { _t } from "../../../languageHandler";
import dis from "../../../dispatcher/dispatcher";
import { ContextMenuTooltipButton } from "../../../accessibility/context_menu/ContextMenuTooltipButton";
import { toRightOf, useContextMenu } from "../../structures/ContextMenu";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
Expand Down Expand Up @@ -103,6 +104,12 @@ export const SpaceButton: React.FC<IButtonProps> = ({
/>;
}

const onClick = props.onClick ?? (selected ?
(space ?
() => dis.dispatch({ action: "view_room", room_id: space.roomId }) :
() => dis.dispatch({ action: "view_home_page" })) :
() => SpaceStore.instance.setActiveSpace(spaceKey ?? space.roomId));

return (
<AccessibleTooltipButton
{...props}
Expand All @@ -112,7 +119,7 @@ export const SpaceButton: React.FC<IButtonProps> = ({
mx_SpaceButton_narrow: isNarrow,
})}
title={label}
onClick={spaceKey ? () => SpaceStore.instance.setActiveSpace(spaceKey) : props.onClick}
onClick={onClick}
onContextMenu={openMenu}
forceHide={!isNarrow || menuDisplayed}
inputRef={handle}
Expand Down Expand Up @@ -261,12 +268,6 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
}
};

private onClick = (ev: React.MouseEvent) => {
ev.preventDefault();
ev.stopPropagation();
SpaceStore.instance.setActiveSpace(this.props.space.roomId);
};

render() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { space, activeSpaces, isNested, isPanelCollapsed, onExpand, parents, innerRef, dragHandleProps,
Expand Down Expand Up @@ -328,7 +329,6 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
notificationState={notificationState}
isNarrow={isPanelCollapsed}
avatarSize={isNested ? 24 : 32}
onClick={this.onClick}
onKeyDown={this.onKeyDown}
ContextMenuComponent={this.props.space.getMyMembership() === "join" ? SpaceContextMenu : undefined}
>
Expand Down