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

Commit

Permalink
Prevent soft crash around room list header context menu when space ch…
Browse files Browse the repository at this point in the history
…anges under it
  • Loading branch information
t3chguy committed Apr 12, 2022
1 parent 7600182 commit cc15cd6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/views/rooms/RoomListHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => {
}
});

useEffect(() => {
if (mainMenuDisplayed && !activeSpace && spaceKey !== MetaSpace.Home) {
// Space changed under us and we no longer has a main menu to draw
closeMainMenu();
}
}, [closeMainMenu, activeSpace, spaceKey, mainMenuDisplayed]);

// we pass null for the queryLength to inhibit the metrics hook for when there is no filterCondition
useWebSearchMetrics(count, filterCondition ? filterCondition.search.length : null, false);

Expand Down Expand Up @@ -168,7 +175,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => {
const canShowPlusMenu = canCreateRooms || canExploreRooms || activeSpace;

let contextMenu: JSX.Element;
if (mainMenuDisplayed) {
if (mainMenuDisplayed && mainMenuHandle.current) {
let ContextMenuComponent;
if (activeSpace) {
ContextMenuComponent = SpaceContextMenu;
Expand Down

0 comments on commit cc15cd6

Please sign in to comment.