diff --git a/umap/static/umap/js/modules/rendering/ui.js b/umap/static/umap/js/modules/rendering/ui.js index 0311cce4..ffa4fe73 100644 --- a/umap/static/umap/js/modules/rendering/ui.js +++ b/umap/static/umap/js/modules/rendering/ui.js @@ -89,7 +89,7 @@ const FeatureMixin = { const items = this._map.getContextMenuItems(event) items.push('-', ...this.feature.getContextMenuItems(event)) this._map.contextmenu.open( - [event.originalEvent.clientX, event.originalEvent.clientY], + [event.originalEvent.pageX, event.originalEvent.pageY], items ) }, diff --git a/umap/static/umap/js/modules/tableeditor.js b/umap/static/umap/js/modules/tableeditor.js index 630360f1..7c13f5ad 100644 --- a/umap/static/umap/js/modules/tableeditor.js +++ b/umap/static/umap/js/modules/tableeditor.js @@ -64,7 +64,7 @@ export default class TableEditor extends WithTemplate { action: () => this.deleteProperty(property), }) } - this.contextmenu.open([event.clientX, event.clientY], actions) + this.contextmenu.open([event.pageX, event.pageY], actions) } renderHeaders() { diff --git a/umap/static/umap/js/modules/ui/base.js b/umap/static/umap/js/modules/ui/base.js index 7fa21748..67f17b0f 100644 --- a/umap/static/umap/js/modules/ui/base.js +++ b/umap/static/umap/js/modules/ui/base.js @@ -63,18 +63,16 @@ export class Positioned { else this.container.style.bottom = 'initial' } - computePosition([x, y], parent) { + computePosition([x, y]) { let left let top - x = x - parent.getBoundingClientRect().left - y = y - parent.getBoundingClientRect().top - if (x < parent.offsetWidth / 2) { + if (x < window.offsetWidth / 2) { left = x } else { left = x - this.container.offsetWidth } - if (y < parent.offsetHeight / 2) { - top = Math.min(y, parent.offsetHeight - this.container.offsetHeight) + if (y < window.offsetHeight / 2) { + top = Math.min(y, window.offsetHeight - this.container.offsetHeight) } else { top = Math.max(0, y - this.container.offsetHeight) } diff --git a/umap/static/umap/js/modules/ui/contextmenu.js b/umap/static/umap/js/modules/ui/contextmenu.js index 305daea1..fd61c84a 100644 --- a/umap/static/umap/js/modules/ui/contextmenu.js +++ b/umap/static/umap/js/modules/ui/contextmenu.js @@ -36,12 +36,11 @@ export default class ContextMenu extends Positioned { this.container.appendChild(li) } } - const parent = document.elementFromPoint(left, top).closest('.leaflet-container') - parent.appendChild(this.container) + document.body.appendChild(this.container) if (this.options.fixed) { this.setPosition({ left, top }) } else { - this.computePosition([left, top], parent) + this.computePosition([left, top]) } this.container.querySelector('li > *').focus() this.container.addEventListener( diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index cfc2c018..8057ec2c 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1773,7 +1773,7 @@ U.Map = L.Map.extend({ onContextMenu: function (event) { const items = this.getContextMenuItems(event) this.contextmenu.open( - [event.originalEvent.clientX, event.originalEvent.clientY], + [event.originalEvent.pageX, event.originalEvent.pageY], items ) },