diff --git a/umap/static/umap/js/modules/rendering/ui.js b/umap/static/umap/js/modules/rendering/ui.js index 034962aef..6c3972dcf 100644 --- a/umap/static/umap/js/modules/rendering/ui.js +++ b/umap/static/umap/js/modules/rendering/ui.js @@ -86,8 +86,9 @@ const FeatureMixin = { onContextMenu: function (event) { DomEvent.stop(event) - const items = this._map.getContextMenuItems(event) - items.push('-', ...this.feature.getContextMenuItems(event)) + const items = this.feature + .getContextMenuItems(event) + .concat(this._map.getContextMenuItems(event)) this._map.contextmenu.open(event.originalEvent, items) }, diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index eda9676fb..bb399b078 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1688,7 +1688,7 @@ U.Map = L.Map.extend({ this.loader.onAdd(this) }, - getContextMenuItems: function (event) { + getOwnContextMenuItems: function (event) { const items = [] if (this.hasEditMode()) { if (this.editEnabled) { @@ -1757,6 +1757,11 @@ U.Map = L.Map.extend({ action: () => this.search(), } ) + return items + }, + + getContextMenuItems: function (event) { + const items = [] if (this.options.urls.routing) { items.push('-', { label: L._('Directions from here'), @@ -1773,7 +1778,9 @@ U.Map = L.Map.extend({ }, onContextMenu: function (event) { - const items = this.getContextMenuItems(event) + const items = this.getOwnContextMenuItems(event).concat( + this.getContextMenuItems(event) + ) this.contextmenu.open(event.originalEvent, items) },