Table/TreeTable exhibits very annoying auto scrolling behavior to selected

I have a selectable treetable with a number of items, and when i expand one, I have an ExpandListener that adds additional items. My problem is:

  1. Select an item, say, the first item.
  2. Scroll down a little ways so the selected item is off the screen
  3. Expand the bottom item in view

The table will then scroll so the selected item is at the top of the screen, and the item expanded is no longer in view.

I have tried messing with setPageLength() and setCurrentPageFirstItemId/Index(), but nothing I have tried can seem to override this behavior, but of course it is possible I have overlooked something.

Here is a code snippet that shows the problem. Thanks in advance for any help anyone can provide!

   private TreeTable table;

    @Override
    protected void init( VaadinRequest request ) {
        final VerticalLayout layout = new VerticalLayout();
        table = new TreeTable();
        table.addExpandListener( event -> {
            if ( !table.isCollapsed( event.getItemId() ) ) {
                for ( int i = 0 ; i < 20 ; i++ ) {
                    Object id = addItem( "SubItem " + i );
                    table.setParent( id, event.getItemId() );
                }
            }
        } );
        table.addContainerProperty( "Name", String.class, null );
        table.setVisibleColumns( "Name" );
        table.setSelectable( true );
        for ( int i = 0 ; i < 200 ; i++ ) {
            addItem( "Item " + i );
        }
        layout.setMargin( true );
        layout.setWidth( "100%" );
        setContent( layout );
        layout.addComponent( table );
    }

    @SuppressWarnings( "unchecked" )
    private Object addItem( String string ) {
        Object id = table.addItem();
        table.getItem( id ).getItemProperty( "Name" ).setValue( string );
        return id;
    }

Anyone have any ideas? Thanks in advance!

bump