mstahv / v-leaflet

Leaflet add-on for Vaadin
Other
43 stars 38 forks source link

'Click' event fired incorrectly on 'contextmenu' #147

Open octavm opened 7 years ago

octavm commented 7 years ago

While running the 'ContextClickOnMap' test case, I performed a right mouse button click(contextmenu) on the polygon and the left mouse button click listener (click) is fired(incorrect behavior).

The message 'Std Click at polygon at [...]' is printed on the screen even though I pressed right mouse button.

basisbit commented 7 years ago

please provide example code to reproduce your issue

octavm commented 7 years ago

The example code is in the ContextClickOnMap class from the test folder. Run the UiRunner class, navigate to localhost:9998 and select the 'ContextClickOnMap' test case.

michaz commented 6 years ago

I'm facing this issue, too. Also, the map gets events which should be caught by the layer. It seems that

        polygon.setNonBubblingEvents(new String[]{"click", "contextmenu"});

doesn't do anything. At least what I see would be consistent with that.

mstahv commented 6 years ago

LeafletJS API has been changed and you can now just toggle whether mouse events should be bubbled or not. I changed that to g-leaflet and v-leaflet. Let me know if this would work for you? There is a similar option for Marker, I guess that would be needed as well in some cases?

octavm commented 6 years ago

Thanks for looking into this. I updated my sources, ran the test case again, and indeed the click/contextclick event on the polygon is not propagated to the map anymore.

But what I find peculiar is that when performing a contextclick on the polygon, the standard click listener of the polygon is also notified. Is this expected behavior ?

mstahv commented 6 years ago

I think it is. That is a click even as well, but with mouseEvent=RIGHT. I think you have to check it to be left click if you need to separate those in your click listener.

I think map don't support it at this point, but there could in theory be other ways to open context menu, like long touch event or "force touch".

michaz commented 6 years ago

Works for me, too, thank you!