Skip to content

Conversation

@ShaneK
Copy link
Member

@ShaneK ShaneK commented Jul 23, 2025

Issue number: resolves internal


What is the current behavior?

Currently, if you use infinite scroll and fully change out elements in the DOM, you'll lose your scroll position. This can present as a race condition in some frameworks, like React, but will present pretty consistently in vanilla JavaScript. This happens because the browser is removing the old elements from the DOM and adding the new ones, and during that time the container holding the old elements will shrink and the browser will adjust the top position to be the maximum of the new container height.

What is the new behavior?

With this new property (preserveRerenderScrollPosition) set, we will loop through siblings of the infinite scroll and set their min-heights to be their current heights before triggering the ionInfinite event, then we clean up after complete is called by restoring their previous min-heights or setting them to auto if there were none. This prevents the container from resizing and the browser from losing the scroll position.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Current dev build:

8.6.6-dev.11753719591.13a5c65f

… that allows infinite scroll to keep the scroll position during a full re-render of its contents
@ShaneK ShaneK requested a review from a team as a code owner July 23, 2025 15:20
@ShaneK ShaneK requested a review from brandyscarney July 23, 2025 15:20
@vercel
Copy link

vercel bot commented Jul 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2025 5:22pm

…lready locked, prevent useless setTimeout from being set up while preserve rerender scroll property isn't set
@github-actions github-actions bot removed the package: angular @ionic/angular package label Jul 28, 2025
Copy link
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🚀

@ShaneK ShaneK merged commit 344a43f into next Jul 30, 2025
96 of 104 checks passed
@ShaneK ShaneK deleted the FW-6668-next branch July 30, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package package: core @ionic/core package package: vue @ionic/vue package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants