Skip to content

Commit

Permalink
fix(nav) avoid navigation open/close on first paint, avoid closing me…
Browse files Browse the repository at this point in the history
…nu on resize for mobile (due to url bar hiding the resize is triggered while browsing the nav)
  • Loading branch information
edlerd committed Jun 8, 2023
1 parent 86e057f commit 975e747
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/context/menuCollapsed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import useEventListener from "@use-it/event-listener";
import { isWidthBelow } from "util/helpers";

const isSmallScreen = () => isWidthBelow(620);
const isMediumScreen = () => isWidthBelow(820);

export const useMenuCollapsed = () => {
const [menuCollapsed, setMenuCollapsed] = useState(false);
const [menuCollapsed, setMenuCollapsed] = useState(isMediumScreen());

const collapseOnMediumScreen = (e: Event) => {
if (isSmallScreen()) {
return;
}
if (!("detail" in e) || e.detail !== "search-and-filter") {
setMenuCollapsed(isWidthBelow(820));
setMenuCollapsed(isMediumScreen());
}
};

Expand Down

0 comments on commit 975e747

Please sign in to comment.