Fixed XF.pageLoadScrollFix() causes browsers to lose scroll position on reload

Steffen

Well-known member
Affected version
2.2.7
How to reproduce:
  1. Open a XenForo page with an anchor link: https://xenforo.com/community/threa...importers-1-5-1-released.198197/#post-1538490
  2. Scroll up or down a bit (away from the anchor link)
  3. Reload the page
What should have happened: The browser should have kept the new scroll position, i.e. it should not scroll back to the anchor link. (This is the default behavior of all browsers as you can test for example here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#browser_compatibility)

What actually happens: The browser scrolls back to the anchor link. This is annoying in particular when you've opened a thread via an "unread" link and then (after you've read all unread posts) reload the page to see whether further replies have arrived.

This issue doesn't affect Chrome Desktop (don't know why) but it affects Firefox Desktop and Safari Desktop. On mobile it affects Chrome, too (haven't tested other browsers).

Originally reported here: https://www.computerbase.de/forum/threads/automatisches-setzen-eines-ankers-in-einem-thread.2053585/

I can fix this issue by removing the call to "XF.pageLoadScrollFix" in core.js. Its purpose seems to be to fix the scroll position after post-load layout-shift has happened. Since layout shift caused by images has been fixed I think the only layout shift remaining in XenForo is caused by embeds, right? Video embeds in particular should be fine because their aspect ratio is known a priori, probably the main remaining issue are Twitter embeds. And maybe in modern browsers scroll anchoring takes care of the remaining cases automatically? So maybe "XF.pageLoadScrollFix" is not needed anymore?
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.8).

Change log:
Disable page load scroll adjustment on browsers supporting native scroll anchoring
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom