Vaadin 8 Tree jumps to selection on expand

I’m using a Tree inside a Panel and if enough elements are expanded it becomes scrollable. And the problem is if the currently selected item is outside the visible area then expanding/collapsing another element makes it jump to the selection causing it to scroll away.
What could be a solution to this?

You should not use Panel then. Tree has its own scrollbar too and scrollTo(row) method where row is row index.

I think you are talking about a TreeGrid but I’m using a simple Tree.

Maybe you could try using a TreeGrid instead?

Unfortunately that is not an option right now. I’m fixing an issue in an existing system, and rewriting is not an option.