diff --git a/src/components/ContextMenu/ContextMenu.react.js b/src/components/ContextMenu/ContextMenu.react.js index 385bbdff2..98d44425a 100644 --- a/src/components/ContextMenu/ContextMenu.react.js +++ b/src/components/ContextMenu/ContextMenu.react.js @@ -7,7 +7,7 @@ */ import PropTypes from 'lib/PropTypes'; -import React, { useState, useEffect, useRef } from 'react'; +import React, { useState, useEffect, useLayoutEffect, useRef } from 'react'; import styles from 'components/ContextMenu/ContextMenu.scss'; const getPositionToFitVisibleScreen = (ref, offset = 0) => { @@ -65,7 +65,7 @@ const MenuSection = ({ level, items, path, setPath, hide, hoveredItemOffset }) = const basePosition = useRef(null); const initialParentScrollTop = useRef(0); - useEffect(() => { + useLayoutEffect(() => { // Use the actual pixel offset of the hovered item instead of index-based calculation const newPosition = getPositionToFitVisibleScreen(sectionRef, hoveredItemOffset); if (newPosition) { @@ -110,7 +110,11 @@ const MenuSection = ({ level, items, path, setPath, hide, hoveredItemOffset }) = opacity: 1, position: 'absolute', } - : {}; + : { + opacity: 0, + position: 'absolute', + pointerEvents: 'none', + }; return (