Topics jumping to wrong post

Thanks so much for the clear reproduction steps @Don :pray:

Yup, that’s it! Two things going on here at the same time

  1. Loading slider service needs to remove the still-loading class from the body
  2. LockOn needs to scroll to the right place

They were both scheduled in the afterRender part of Ember’s runloop. And since the ‘lock on’ stuff is technically scheduled first, it was being run first. And so LockOn was running while all the post HTML was in the DOM, but still had display: none. :grimacing:

This PR will move the still-loading class removal to the ‘render’ part of the runloop, which means anything else which is scheduling stuff afterRender will be running once everything is rendered and visible:

Agreed! I didn’t want to touch it as part of this bugfix, but I think we should aim to remove all those hacks.

Reading the comments in the file, it looks like it was originally introduced (10 years ago!) to counteract browser ‘scroll restoration’ features. Nowadays, we use history.scrollRestoration = false to disable that browser feature, so I think that makes most of the old hacks redundant.

Probably best to trial this kind of sensitive change via a theme component first, and then if it all looks good we can merge into core. I imagine removing LockOn will fix a lot of other edge-cases we have with topic scroll position. I’ll aim to try this out in the next couple of weeks :technologist:

7 Likes