mstahv / v-leaflet

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

ContextMenu disappears immedately if opened on different marker #139

Closed dominic-simplan closed 7 years ago

dominic-simplan commented 7 years ago

Hi,

if the ContextMenu (I am using the official Vaadin Add-on) is opened on one marker, and I make a right-click on a second marker, the context menu on the first marker disappears (which is fine) and the context menu for the second marker appears for less than a second and immediately disappears again.

To make it even more curious: This only happens if the right-click is "fast" enough. If I make a slow right-click (i.e. holding down the mouse button a little longer before releasing it), it works as expected.

Happens on both Chrome and Firefox.

Example layout to reproduce:

public class LocationLayout extends VerticalLayout {

    public LocationLayout() {
        setSizeFull();
        LMap map = new LMap();
        LTileLayer osmTiles = new LOpenStreetMapLayer();
        map.addBaseLayer(osmTiles, null);
        map.setSizeFull();

        LMarker marker = new LMarker(40, 2);
        map.addComponent(marker);
        LMarker marker2 = new LMarker(45, 3);
        map.addComponent(marker2);

        ContextMenu menu = new ContextMenu(map, false);
        menu.addItem("Test 1", null);
        menu.addItem("Test 2", null);

        LeafletContextMenuListener listener = new LeafletContextMenuListener() {
            @Override
            public void onContextMenu(LeafletContextMenuEvent event) {
                menu.open((int) event.getClientX(), (int) event.getClientY());
            }
        };
        marker.addContextMenuListener(listener);
        marker2.addContextMenuListener(listener);

        addComponent(map);
        map.flyTo(new Point(40, 2), 2.0);
    }
}

Related dependencies:

<dependency>
            <groupId>com.vaadin.addon</groupId>
            <artifactId>vaadin-context-menu</artifactId>
            <version>0.7.4</version>
</dependency>

<dependency>
            <groupId>org.vaadin.addon</groupId>
            <artifactId>v-leaflet</artifactId>
            <version>1.0.3</version>
</dependency>

Any ideas?

Best regards, Dominic

mstahv commented 7 years ago

Don't know what happens, will need to debug this some day.

basisbit commented 7 years ago

@dominic-simplan can you still reproduce this issue with vaadin 8.1.5? Seems to be fixed now. (at least I can not reproduce this issue any more, but saw it occasionally before, and it was independent from v-leaflet anyways).

mstahv commented 7 years ago

OK, then it was probably an issue in the context menu or the vaadin side hooks. Will close this, thanks a lot for the report!