From bc6082ca8929ca770827854a6055372172df9aa8 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Fri, 10 Apr 2020 09:47:41 +0000 Subject: [PATCH] Fixed wrong position of rename menu --- src/app/ui/contextMenu.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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)