Initial scrolling to programmatically selected tree node does not work in V8 anymore (Vaadin 8.1.5, IE 11)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
I migrated the following V7 example
package example_v7;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import java.util.stream.IntStream;
@Widgetset("com.vaadin.v7.Vaadin7WidgetSet")
@SpringUI
public class SelectedTreeNodeScrollingIssueV7UI extends UI {
@Override
protected void init(VaadinRequest request) {
com.vaadin.v7.ui.Tree tree = new com.vaadin.v7.ui.Tree();
tree.addItem("Mercury");
tree.addItem("Venus");
tree.addItem("Earth");
tree.addItem("MorePlanets");
IntStream.rangeClosed(1, 100).forEach(value -> {
final String itemId = "Planet" + value;
tree.addItem(itemId);
tree.setParent(itemId, "MorePlanets");
});
tree.addItem("EvenMorePlanets");
IntStream.rangeClosed(1, 100).forEach(value -> {
final String itemId = "AnotherPlanet" + value;
tree.addItem(itemId);
tree.setParent(itemId, "EvenMorePlanets");
});
Panel panel = new Panel(tree);
panel.setWidth("50%");
panel.setHeight("50%");
tree.expandItem("EvenMorePlanets");
tree.select("AnotherPlanet50"); //HERE HERE HERE!
VerticalLayout verticalLayout = new VerticalLayout(panel);
verticalLayout.setWidth("100%");
verticalLayout.setHeight("100%");
setContent(verticalLayout);
}
}
to V8
package example_v8;
import com.vaadin.data.TreeData;
import com.vaadin.data.provider.TreeDataProvider;
import com.vaadin.server.VaadinRequest;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Tree;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import java.util.stream.IntStream;
@SpringUI
public class SelectedTreeNodeScrollingIssueV8UI extends UI {
@Override
protected void init(VaadinRequest request) {
TreeData<String> treeData = new TreeData<>();
treeData.addItem(null, "Mercury");
treeData.addItem(null, "Venus");
treeData.addItem(null, "Earth");
treeData.addItem(null, "MorePlanets");
IntStream.rangeClosed(1, 100).forEach(value -> treeData.addItem("MorePlanets", "Planet" + value));
treeData.addItem(null, "EvenMorePlanets");
IntStream.rangeClosed(1, 100).forEach(value -> treeData.addItem("EvenMorePlanets", "AnotherPlanet" + value));
TreeDataProvider<String> inMemoryDataProvider = new TreeDataProvider<>(treeData);
Tree<String> tree = new Tree<>(inMemoryDataProvider);
Panel panel = new Panel(tree);
panel.setHeight("50%");
panel.setWidth("50%");
tree.expand("EvenMorePlanets");
tree.select("AnotherPlanet50"); //HERE HERE HERE!
VerticalLayout verticalLayout = new VerticalLayout(panel);
verticalLayout.setWidth("100%");
verticalLayout.setHeight("100%");
setContent(verticalLayout);
}
}
In the V7 version, the UI opens and I immediately see the selected node, the scrollbar is at the "right position" (around the middle).
In the V8 version, the scrollbar is at the top and I first must scroll down to see the selected node.
It would be nice to have the V7 behaviour also in V8. We have a tree in a "selection window popup" where the user can pick a node. Before the "selection window popup" opens, the current value is "pre-selected" programmatically.
I also don't see a workaround, because I don't see a way to scroll the tree programmatically.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Vaadin 8 Tree selection and scrolling behavior, using the provided SelectedTreeNodeScrollingIssueV8UI example and comparing it with the V7 version. Reproduce the issue in IE 11 with EvenMorePlanets expanded and AnotherPlanet50 selected; done means the selected node is initially visible with the scrollbar positioned around it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 28/100