Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 33c900e

Browse files
authored
Remove right panel toggling behaviour on room header buttons (#100)
* Remove right panel toggling behaviour on room header buttons Signed-off-by: Michael Telatynski <[email protected]> * Remove stale test Signed-off-by: Michael Telatynski <[email protected]> * Fix tests Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent 81bb56a commit 33c900e

File tree

6 files changed

+11
-43
lines changed

6 files changed

+11
-43
lines changed

playwright/e2e/read-receipts/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ class Helpers {
395395
*/
396396
async closeThreadsPanel() {
397397
await this.page.locator(".mx_RoomHeader").getByLabel("Threads").click();
398+
if (await this.page.locator("#thread-panel").isVisible()) {
399+
await this.page.locator(".mx_RoomHeader").getByLabel("Threads").click();
400+
}
398401
await expect(this.page.locator(".mx_RightPanel")).not.toBeVisible();
399402
}
400403

src/components/views/rooms/RoomHeader.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export default function RoomHeader({
255255
<button
256256
aria-label={_t("right_panel|room_summary_card|title")}
257257
tabIndex={0}
258-
onClick={() => RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomSummary)}
258+
onClick={() => RightPanelStore.instance.showOrHidePhase(RightPanelPhases.RoomSummary)}
259259
className="mx_RoomHeader_infoWrapper"
260260
>
261261
<Box flex="1" className="mx_RoomHeader_info">
@@ -339,7 +339,7 @@ export default function RoomHeader({
339339
<IconButton
340340
onClick={(evt) => {
341341
evt.stopPropagation();
342-
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomSummary);
342+
RightPanelStore.instance.showOrHidePhase(RightPanelPhases.RoomSummary);
343343
}}
344344
aria-label={_t("right_panel|room_summary_card|title")}
345345
>
@@ -354,7 +354,7 @@ export default function RoomHeader({
354354
indicator={notificationLevelToIndicator(threadNotifications)}
355355
onClick={(evt) => {
356356
evt.stopPropagation();
357-
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.ThreadPanel);
357+
RightPanelStore.instance.showOrHidePhase(RightPanelPhases.ThreadPanel);
358358
PosthogTrackers.trackInteraction("WebRoomHeaderButtonsThreadsButton", evt);
359359
}}
360360
aria-label={_t("common|threads")}
@@ -368,7 +368,7 @@ export default function RoomHeader({
368368
indicator={notificationLevelToIndicator(globalNotificationState.level)}
369369
onClick={(evt) => {
370370
evt.stopPropagation();
371-
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.NotificationPanel);
371+
RightPanelStore.instance.showOrHidePhase(RightPanelPhases.NotificationPanel);
372372
}}
373373
aria-label={_t("notifications|enable_prompt_toast_title")}
374374
>
@@ -387,7 +387,7 @@ export default function RoomHeader({
387387
viewUserOnClick={false}
388388
tooltipLabel={_t("room|header_face_pile_tooltip")}
389389
onClick={(e: ButtonEvent) => {
390-
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList);
390+
RightPanelStore.instance.showOrHidePhase(RightPanelPhases.RoomMemberList);
391391
e.stopPropagation();
392392
}}
393393
aria-label={_t("common|n_members", { count: memberCount })}

src/components/views/rooms/RoomHeader/VideoRoomChatButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const VideoRoomChatButton: React.FC<{ room: Room }> = ({ room }) => {
4444
// stop event propagating up and triggering RoomHeader bar click
4545
// which will open RoomSummary
4646
event.stopPropagation();
47-
sdkContext.rightPanelStore.showOrHidePanel(RightPanelPhases.Timeline);
47+
sdkContext.rightPanelStore.showOrHidePhase(RightPanelPhases.Timeline);
4848
};
4949

5050
return (

src/stores/right-panel/RightPanelStore.ts

-17
Original file line numberDiff line numberDiff line change
@@ -228,23 +228,6 @@ export default class RightPanelStore extends ReadyWatchingStore {
228228
}
229229
}
230230

231-
/**
232-
* If the right panel is open, it is closed.
233-
* If the right panel is closed, it is opened with `phase`.
234-
*
235-
* This is different from showOrHidePhase which only closes the panel
236-
* if the panel was already showing the phase passed as argument.
237-
* @see showOrHidePhase
238-
* @param phase The right panel phase.
239-
*/
240-
public showOrHidePanel(phase: RightPanelPhases): void {
241-
if (!this.isOpen) {
242-
this.setCard({ phase });
243-
} else {
244-
this.togglePanel(null);
245-
}
246-
}
247-
248231
/**
249232
* Helper to show a right panel phase.
250233
* If the UI is already showing that phase, the right panel will be hidden.

test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe("<VideoRoomChatButton />", () => {
5656
...mockClientMethodsUser(),
5757
});
5858
rightPanelStore = {
59-
showOrHidePanel: jest.fn(),
59+
showOrHidePhase: jest.fn(),
6060
} as unknown as MockedObject<RightPanelStore>;
6161
sdkContext = new SdkContextClass();
6262
sdkContext.client = client;
@@ -73,7 +73,7 @@ describe("<VideoRoomChatButton />", () => {
7373

7474
fireEvent.click(screen.getByLabelText("Chat"));
7575

76-
expect(sdkContext.rightPanelStore.showOrHidePanel).toHaveBeenCalledWith(RightPanelPhases.Timeline);
76+
expect(sdkContext.rightPanelStore.showOrHidePhase).toHaveBeenCalledWith(RightPanelPhases.Timeline);
7777
});
7878

7979
it("renders button with an unread marker when room is unread", () => {

test/stores/right-panel/RightPanelStore-test.ts

-18
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,4 @@ describe("RightPanelStore", () => {
217217
await viewRoom("!1:example.org");
218218
expect(store.currentCardForRoom("!1:example.org").phase).toEqual(RightPanelPhases.RoomMemberList);
219219
});
220-
221-
it("showOrHidePhase works as expected", async () => {
222-
await viewRoom("!1:example.org");
223-
224-
// Open the memberlist panel
225-
store.showOrHidePanel(RightPanelPhases.RoomMemberList);
226-
expect(store.isOpenForRoom("!1:example.org")).toEqual(true);
227-
expect(store.currentCardForRoom("!1:example.org").phase).toEqual(RightPanelPhases.RoomMemberList);
228-
229-
// showOrHide with RoomSummary should now close the panel
230-
store.showOrHidePanel(RightPanelPhases.RoomSummary);
231-
expect(store.isOpenForRoom("!1:example.org")).toEqual(false);
232-
233-
// showOrHide with RoomSummary should now open the panel
234-
store.showOrHidePanel(RightPanelPhases.RoomSummary);
235-
expect(store.isOpenForRoom("!1:example.org")).toEqual(true);
236-
expect(store.currentCardForRoom("!1:example.org").phase).toEqual(RightPanelPhases.RoomSummary);
237-
});
238220
});

0 commit comments

Comments
 (0)