vaadin / context-menu

Vaadin ContextMenu
Apache License 2.0
11 stars 21 forks source link

Up/down cursor in context menu not working correctly #89

Closed sirbris closed 6 years ago

sirbris commented 6 years ago

When I open the context menu and use down cursor it skips one entry, as if one would have used down cursor twice. Same with the up-key.

anasmi commented 6 years ago

Hi @sirbris,

I have tried today to reproduce the issue using the demo within the add-on, but I haven't managed so far. My steps were:

Therefore, could you, please, share the demo application which illustrates the problem? Or, if it's not possible, to share gif/picture and describe your actions, that we would be able to reproduce the problem on our side also,

Thanks in advance!

sirbris commented 6 years ago

Here's a simple example:

    public class TestBean {
        private String name = "name";
        private String value = "value";
        private boolean folder = false;

        public TestBean(boolean inFolder) {
            folder = inFolder;
        }

        public String getName() {
            return name;
        }

        public void setName(String inName) {
            name = inName;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String inValue) {
            value = inValue;
        }

        public void setFolder(boolean inFolder) {
            folder = inFolder;
        }

        public boolean isFolder() {
            return folder;
        }

    }

    private Grid<TestBean> grid = new Grid<TestBean>(TestBean.class);
    private GridContextMenu<TestBean> contextMenu = new GridContextMenu<>(grid);
    private ArrayList<TestBean> items = new ArrayList<>();

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        grid.setDataProvider(new ListDataProvider<>(items));
        grid.setWidth("100%");
        grid.setHeight("400px");

        layout.addComponent(grid);

        contextMenu.addContextMenuOpenListener(event -> handleOpen(event));
    }

    private void handleOpen(ContextMenuOpenEvent inEvent) {
        contextMenu.removeItems();
        contextMenu.addItem("test1", event -> System.out.println("clicked 1"));
        contextMenu.addItem("test2", event -> System.out.println("clicked 2"));
        contextMenu.addItem("test3", event -> System.out.println("clicked 3"));
        contextMenu.addItem("test4", event -> System.out.println("clicked 4"));
        contextMenu.addItem("test5", event -> System.out.println("clicked 5"));
    }
anasmi commented 6 years ago

Thanks for the example! :)

Just to be sure, what version of Vaadin are you using?

I have tried to run the demo under context-menu itself, and everything works as expected; also it seems that it works alright in 8.1.7, but 8.4.3 produces already the behavior you see. Therefore, it looks like some change in the framework has affected the work of the addon, but it will require more investigation to be sure, of course.

sirbris commented 6 years ago

I use the current Vaadin 8.4.3 and also the current ContextMenu 2.1.0

anasmi commented 6 years ago

alright, thanks! : )