From c844e1c03d4c84c7f427473446d8acd286e5277f Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 5 Oct 2024 11:22:02 +0200 Subject: [PATCH] chore: use position: fixed for contextmenu --- umap/static/umap/css/contextmenu.css | 2 +- umap/static/umap/js/modules/ui/contextmenu.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/css/contextmenu.css b/umap/static/umap/css/contextmenu.css index e7ed2508..79b55c09 100644 --- a/umap/static/umap/css/contextmenu.css +++ b/umap/static/umap/css/contextmenu.css @@ -1,7 +1,7 @@ .umap-contextmenu { background-color: var(--background-color); padding: calc(var(--box-padding) / 2) var(--box-padding); - position: absolute; + position: fixed; z-index: var(--zindex-contextmenu); border-radius: var(--border-radius); box-shadow: var(--block-shadow); diff --git a/umap/static/umap/js/modules/ui/contextmenu.js b/umap/static/umap/js/modules/ui/contextmenu.js index d385e492..e85c562b 100644 --- a/umap/static/umap/js/modules/ui/contextmenu.js +++ b/umap/static/umap/js/modules/ui/contextmenu.js @@ -16,8 +16,8 @@ export default class ContextMenu extends Positioned { } open(event, items) { - const left = event.pageX - const top = event.pageY + const left = event.clientX + const top = event.clientY this.container.innerHTML = '' for (const item of items) { if (item === '-') { @@ -38,7 +38,7 @@ export default class ContextMenu extends Positioned { this.container.appendChild(li) } } - const parent = document.elementFromPoint(event.clientX, event.clientY).offsetParent + const parent = document.elementFromPoint(left, top).offsetParent parent.appendChild(this.container) if (this.options.fixed) { this.setPosition({ left, top })