From 76654e65dec79a621da19e9eba8db3f634fdddfa Mon Sep 17 00:00:00 2001 From: jelveh Date: Thu, 26 Dec 2024 13:43:34 -0800 Subject: [PATCH] Fix the issue with contextmenu going completely nuts when opened near the right edge of the screen --- src/gui/src/UI/UIContextMenu.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/src/UI/UIContextMenu.js b/src/gui/src/UI/UIContextMenu.js index 6bf541ec4..6a14fb0fb 100644 --- a/src/gui/src/UI/UIContextMenu.js +++ b/src/gui/src/UI/UIContextMenu.js @@ -537,12 +537,13 @@ function UIContextMenu(options){ let x_pos; if( start_x + menu_width > window.innerWidth){ x_pos = start_x - menu_width; - // if this is a child menu, the width of parent must be also considered - if(options.parent_id){ + // if this is a child menu, the width of parent must also be considered + if(options.parent_id && $(`.context-menu[data-element-id="${options.parent_id}"]`).length > 0){ x_pos -= $(`.context-menu[data-element-id="${options.parent_id}"]`).width() + 30; } - }else + }else{ x_pos = start_x + } // Y position let y_pos;