From 0b954383180d55a3d7228ac549b4cc740c31c611 Mon Sep 17 00:00:00 2001 From: agriyadev5 Date: Fri, 4 Jun 2021 14:08:21 +0530 Subject: [PATCH] #566 When you display the context panel on the right of the screen, the text is not aligned --- src/editor/dialogs/cmenuDialog.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/editor/dialogs/cmenuDialog.js b/src/editor/dialogs/cmenuDialog.js index 8e608daf..d19b4642 100644 --- a/src/editor/dialogs/cmenuDialog.js +++ b/src/editor/dialogs/cmenuDialog.js @@ -306,8 +306,21 @@ export class SeCMenuDialog extends HTMLElement { const current = this; const onMenuOpenHandler = (e) => { e.preventDefault(); - current.$dialog.style.top = e.pageY + 'px'; - current.$dialog.style.left = e.pageX + 'px'; + // Detect mouse position + let x = e.pageX; + let y = e.pageY; + + const xOff = screen.width - 250; // menu width + const yOff = screen.height - (276 + 150); // menu height + bottom panel height and scroll bar + + if (x > xOff) { + x = xOff; + } + if (y > yOff) { + y = yOff; + } + current.$dialog.style.top = y + 'px'; + current.$dialog.style.left = x + 'px'; current.$dialog.style.display = 'block'; }; const onMenuCloseHandler = (e) => {