From 765c7cdc273eb0c03c926ef04aca1cfce7ecda11 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Sep 2021 17:19:00 -0700 Subject: [PATCH] fix: Max menu height should not affect mobile context menus --- app/components/ContextMenu/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/components/ContextMenu/index.js b/app/components/ContextMenu/index.js index d6ea66931d..c215051d96 100644 --- a/app/components/ContextMenu/index.js +++ b/app/components/ContextMenu/index.js @@ -4,6 +4,7 @@ import { Portal } from "react-portal"; import { Menu } from "reakit/Menu"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; +import useMobile from "hooks/useMobile"; import usePrevious from "hooks/usePrevious"; import useWindowSize from "hooks/useWindowSize"; import { @@ -35,8 +36,9 @@ export default function ContextMenu({ }: Props) { const previousVisible = usePrevious(rest.visible); const [maxHeight, setMaxHeight] = React.useState(undefined); - const backgroundRef = React.useRef(); + const isMobile = useMobile(); const { height: windowHeight } = useWindowSize(); + const backgroundRef = React.useRef(); React.useEffect(() => { if (rest.visible && !previousVisible) { @@ -56,7 +58,7 @@ export default function ContextMenu({ React.useLayoutEffect(() => { const padding = 8; - if (rest.visible) { + if (rest.visible && !isMobile) { setMaxHeight( rest.unstable_disclosureRef?.current ? windowHeight - @@ -66,7 +68,7 @@ export default function ContextMenu({ : undefined ); } - }, [rest.visible, rest.unstable_disclosureRef, windowHeight]); + }, [rest.visible, rest.unstable_disclosureRef, windowHeight, isMobile]); return ( <>