fix(ncontextmenu): smart positionning to avoid clipping outside of parent.

This commit is contained in:
Lemmy
2026-03-29 10:00:27 -04:00
parent 9d5bc13000
commit 9a2f676753
+7
View File
@@ -140,6 +140,13 @@ Popup {
// Helper function to open at mouse position
function openAt(x, y) {
if (root.parent) {
var menuWidth = root.width;
var itemCount = root.filteredModel.length;
var menuHeight = Math.max(itemCount * root.itemHeight + Math.max(0, itemCount - 1) * listView.spacing, root.itemHeight) + root.topPadding + root.bottomPadding;
x = Math.max(0, Math.min(x, root.parent.width - menuWidth));
y = Math.max(0, Math.min(y, root.parent.height - menuHeight));
}
root.x = x;
root.y = y;
root.open();