inertia icon indicating copy to clipboard operation
inertia copied to clipboard

Fix a bug with [scroll-region] elements not restoring correct scroll positions in react adapter

Open dsazup opened this issue 1 year ago • 1 comments

Hi, I'm using react and I run into a bug where I have a [scroll-region] element and after navigating back, the scroll position is not restored, even though the page has saved the positions correctly.

This happens because in the restoreScrollPositions method this.scrollRegions() returns an empty array. It thinks that there aren't any [scroll-region] elements, because the document body hasn't been updated yet. Even though there actually is an element. Simply wrapping the whole thing in setTimeout fixes it and positions are restored correctly.

dsazup avatar Feb 12 '24 16:02 dsazup

#1803 also fixes a scroll restoration bug in the React adapter. These PRs conflict with each other but that will be easy to consolidate.

pedroborges avatar Sep 06 '24 19:09 pedroborges