Trees "Jumpy" with ClickListeners


I’ve noticed that when a ClickListener is added to a Tree it becomes much harder to use from a user perspective. Selecting an item is inconsistent, the selection “Jumps” around. An example can be found
(Tree on the left changes directories when double clicked). My ClickListener logic is below for reference.

if (event.isDoubleClick()) {
    changeDirectory((File) event.getItemId());

It doesn’t get much simpler than that :slight_smile:

Is there any way to workaround this issue? Are there plans to fix this in the future? To me this seems like a significant usability bug.


I have one idea. Try to set null selection allowed to false:


This must prevent jump effect. You have to have something likes the following:

        Tree tree = new Tree();
        tree.addItemClickListener(new ItemClickEvent.ItemClickListener() {
            public void itemClick(ItemClickEvent event) {

Thanks for the response - that didn’t work in my case. Removing the ClickListener fixes the problem, but that’s a bit counter-productive :slight_smile:

Any other suggestions are greatly appreciated!

I have a working example based on Vaadin 7.3.4.

May be you have side effect inside the changeDirectory method.

I don’t think that’s the case because this is observed even with a fresh UI, before a double-click event occurs. In any case changeDirectory() only parses the File’s path and redirects the user to a RESTful URI for the folder. Try double clicking the Tree in the example I sent and you’ll see what I mean.

I’ll try upgrading to 7.3.4 and see if that helps.

Do you have own URI handler for uri like this “#!files/Home/Videos”?

No, I handle that with event.getParameters() in the View.enter() method.

I’ll scour my code again and see if I can find anywhere I call setNullSelectionAllowed(true), but I’m 99% sure properties like this aren’t modified elsewhere. I’ll also try to put together a simple example reproducing the issue in my environment.

I will be waiting for the reprocode. Do you use Maven?

I am very happy to report that upgrading from 7.3.0 to 7.3.4 resolved this issue! It did require a widgetset recompile as well.

Thanks for all of the assistance Anatoly. It is very much appreciated. Below is an example I came up with which reproduces the issue in 7.3.0 if anyone is interested.


public class VdnUI extends UI  {
    private static final long serialVersionUID = 1L;
    protected void init(VaadinRequest request) {
        HorizontalLayout content = new HorizontalLayout();
        /* With click listener */
        Tree tree1 = new Tree();
        tree1.addItemClickListener(new ItemClickListener() {
            private static final long serialVersionUID = 1L;

            public void itemClick(ItemClickEvent event) {
        /* Without click listener */
        Tree tree2 = new Tree();
    private void addItems(Tree tree) {
        String items = "Item1 Item2 Item3 Item4";
        tree.addItems((Object) items.split(" "));
        for (String item : items.split(" ")) {
            String child = "Child of " + item;
            tree.setParent(child, item);
            tree.setChildrenAllowed(child, false);