From ffbe4c1b80400289bdeddcb555b53ab55034ca1a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Oct 2023 22:17:18 -0400 Subject: [PATCH] fix: Prevent potential page scroll on context menu open --- app/components/ContextMenu/index.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/components/ContextMenu/index.tsx b/app/components/ContextMenu/index.tsx index c4312d0a0..7d29d0ead 100644 --- a/app/components/ContextMenu/index.tsx +++ b/app/components/ContextMenu/index.tsx @@ -137,7 +137,8 @@ const InnerContextMenu = (props: InnerContextMenuProps) => { // kind of hacky, but this is an effective way of telling which way // the menu will _actually_ be placed when taking into account screen // positioning. - const topAnchor = menuProps.style?.top === "0"; + const topAnchor = + menuProps.style?.top === "0" || menuProps.style?.position === "fixed"; const rightAnchor = menuProps.placement === "bottom-end"; const backgroundRef = React.useRef(null); const isMobile = useMobile(); @@ -162,6 +163,13 @@ const InnerContextMenu = (props: InnerContextMenuProps) => { }; }, [props.isSubMenu, props.visible]); + const style = + topAnchor && !isMobile + ? { + maxHeight, + } + : undefined; + return ( <> {isMobile && ( @@ -181,13 +189,7 @@ const InnerContextMenu = (props: InnerContextMenuProps) => { rightAnchor={rightAnchor} ref={backgroundRef} hiddenScrollbars - style={ - topAnchor && !isMobile - ? { - maxHeight, - } - : undefined - } + style={style} > {props.visible || props.animating ? props.children : null}