Call scroll method after page finished loading


I have a view that displays several Details components containing grids. On leaving the view I save the current Details component and which of the Details components were opened. When I navigate to the view again, I want to open all Details components that were opened last time and scroll to the current Details component. The problem is that the grids in the Details components (which I open on entering) are not finished with loading before the scroll method is called in the afterNavigation() method.

Is there a way to call the scroll method after the page finished loading? I already tried onAttach() but that gets called before afterNavigation().

It kind of works sometimes with a timeout:

        "setTimeout(function(){ document.getElementById(\"" + id + "\")" +
                ".scrollIntoView(); }, " + milliseconds + ");"

Does anybody have a solution to this problem? (I am using Vaadin 14).
Thanks in advance!