Find a better way to close the Radix context/right click menu

Created on 14 February 2025, 2 months ago

Overview

At the moment if a user right clicks a component and then performs another UI action (like zooming the canvas, or adding a new component to the layout) we force the context menu to close to ensure it doesn't get misaligned as the page beneath it shifts.

To close the context menu we fire a 'faked' escape key press event as that was the simplest way to close the context menu.

This causes an issue though with Dialogs - because they ALSO close when the esc key event is fired and we don't want that!

Proposed resolution

Find a better way to programatically close the context menu (without also closing dialogs!) There are two @todo's with this issue's id in them that should be addressed in the codebase.

User interface changes

๐Ÿ“Œ Task
Status

Active

Version

0.0

Component

Page builder

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jessebaker

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jessebaker
  • First commit to issue fork.
  • Pipeline finished with Failed
    about 2 months ago
    Total: 235s
    #443125
  • Pipeline finished with Failed
    about 2 months ago
    Total: 554s
    #443129
  • Pipeline finished with Failed
    about 2 months ago
    Total: 318s
    #443133
  • Pipeline finished with Failed
    about 2 months ago
    Total: 1257s
    #443136
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hitvikav_

    issue #3506657: I have added possible mouse events on which menu should be closed.
    Raised MR for a better way to close the Radix context/right click menu
    Thanks

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia meghasharma

    Instead of directly manipulating the DOM using document.querySelector and menu.style.display = 'none' (lines 84 and 88), we should use Radix UIโ€™s built-in method (if available) to close the menu.

    Can we avoid direct DOM manipulation? Radix UI might change internal class names, which can break the code.
    Can we use state for menu visibility? The menuโ€™s visibility should be controlled using useState.

    const [open, setOpen] = useState(true); // Control menu state
    
    const closeContextMenu = useCallback(() => {
      setOpen(false); // Close the menu using state
    }, []);
  • Pipeline finished with Failed
    about 1 month ago
    Total: 895s
    #452128
Production build 0.71.5 2024