Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fixing context menu position (#10349)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-Zimmer authored Jun 10, 2024
1 parent b950278 commit 39030b8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/ui/src/components/editor/layout/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,10 @@ export const ContextMenu = ({
if (open && menuRef.current) {
const menuHeight = menuRef.current.offsetHeight

// The amount of space that the menu can fill based on the current anchor position
const spaceToBottomFromAnchor = window.innerHeight - anchorPosition.top
// We want to reposition the context menu whenever it will overflow the bottom of the screen
const shouldRepositionMenu = menuHeight > spaceToBottomFromAnchor

if (shouldRepositionMenu) {
// Align the menu bottom with the bottom of the viewport
positionY = window.innerHeight - menuHeight - (panel?.getBoundingClientRect().top || 0) + 30
// if the panel height is less than the menu height plus the menu pos y offset, we need to move the menu up
const offset = panel?.getBoundingClientRect().height! - (menuHeight + positionY)
if (offset < 0) {
positionY = positionY + offset
}
}

Expand Down

0 comments on commit 39030b8

Please sign in to comment.