diff --git a/src/app/ui/contextMenu.js b/src/app/ui/contextMenu.js index ca2e953c79..f97720c6cd 100644 --- a/src/app/ui/contextMenu.js +++ b/src/app/ui/contextMenu.js @@ -45,12 +45,22 @@ module.exports = (event, items) => { current.onclick = () => { hide(null, true); items[item]() } return current }) - const container = yo`
` + const container = yo`` + container.style.left = event.pageX + 'px' container.style.top = event.pageY + 'px' container.style.display = 'block' - document.querySelector('body').appendChild(container) + + const menuItemsContainer = document.getElementById('menuItemsContainer') + const boundary = menuItemsContainer.getBoundingClientRect() + + if (boundary.bottom > (window.innerHeight || document.documentElement.clientHeight)) { + menuItemsContainer.style.position = 'absolute' + menuItemsContainer.style.bottom = '10px' + menuItemsContainer.style.top = null + } + setTimeout(() => { window.addEventListener('click', hide) }, 500)