I am pretty sure that this worked in the past, as I used this method in our app to scroll to an item after adding it to a large tree-structure.
public void scrollToItem(T item) {
expandAncestor(item);
int index = getIndexForItem(item);
if (index >= 0) {
this.getElement().executeJs("this.scrollWhenReady($0, true);", index);
}
}
From debugging, I could observe the following:
- The calculated index seems to be correct (= index counting items from top taking expansion state of items into account)
- The js scrollWhenReady seems to interpret the index as "index of the root-item to scroll to". If index = 10 for example, it scrolls to the 10th root item (or last if there are less), and not to the 10th visual item taking expansion states into account