aratcliffe / Leaflet.contextmenu

A context menu for Leaflet.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

contextmenu fires twice on geojson layers

m00nlighter opened this issue · comments

onEachFeature: function(feature, layer){
            layer.bindContextMenu({
            contextmenu: true,
            contextmenuItems: [{
                text: 'Marker item',
                callback: function (e) {
                    console.log(e);
                }
            }]
        });
    layerGroup.addLayer(layer);
    }

its a simple code how to add menu to geojson data(just like in example) but i always get an object without related target in my console.log so i decided to check what return contextmunu.show event.

map.on('contextmenu.show',function(e){
console.log('Context menu fired on :');
console.log(e);
console.log('-');
})

with this code i see that contextmenu fires twice
on first fire it return object with related target
and on second fire it return object without relatedtarget

you can check it on jsfille example
https://jsfiddle.net/rk9ynv82/

problem was in bubblingMouseEvents
https://jsfiddle.net/rk9ynv82/1/