From 84a92ad670b7fbfa18c450d6c5c5191da1891e3d Mon Sep 17 00:00:00 2001 From: Dwight Kelly Date: Thu, 9 Aug 2018 13:05:18 -0400 Subject: [PATCH 1/2] prevent nested menu from obscuring parent when user clicks towards right edge of window --- contextMenu.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contextMenu.js b/contextMenu.js index c798590..efa0a08 100644 --- a/contextMenu.js +++ b/contextMenu.js @@ -421,7 +421,11 @@ } } else { if (leftCoordinate > menuWidth && winWidth - leftCoordinate - padding < menuWidth) { - leftCoordinate = winWidth - menuWidth - padding; + if(level && level > 0) { + leftCoordinate = leftCoordinate - (1.5 * menuWidth); + } else { + leftCoordinate = winWidth - menuWidth - padding; + } } else if(winWidth - leftCoordinate < menuWidth) { var reduceThresholdX = 5; if(leftCoordinate < reduceThresholdX + padding) { From d1a22f139999071356eb313f6d83456adc4eef4e Mon Sep 17 00:00:00 2001 From: rett gerst Date: Tue, 3 Mar 2020 12:20:02 -0500 Subject: [PATCH 2/2] fix nested menu height logic and a stray window element --- contextMenu.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contextMenu.js b/contextMenu.js index 21b3c88..1aab307 100644 --- a/contextMenu.js +++ b/contextMenu.js @@ -393,7 +393,10 @@ topCoordinate = event.pageY - menuHeight; /// If the element is a nested menu, adds the height of the parent li to the topCoordinate to align with the parent if(level && level > 0) { - topCoordinate += event.event.currentTarget.offsetHeight; + // but not so much that it overflows off the bottom of the window + var maxHeight = $document[0].body.clientHeight - $window.scrollY - menuHeight - 20; + var adjustedHeight = topCoordinate + event.event.currentTarget.offsetHeight; + topCoordinate = Math.min(maxHeight, adjustedHeight); } } else if(winHeight <= menuHeight) { // If it really can't fit, reset the height of the menu to one that will fit @@ -410,7 +413,7 @@ var leftCoordinate = event.pageX; var menuWidth = angular.element($ul[0]).prop('offsetWidth'); - var winWidth = event.view.innerWidth + window.pageXOffset; + var winWidth = event.view.innerWidth + $window.pageXOffset; var padding = 5; if (leftOriented) {