The discussion revolves around a page jump issue that occurs when clicking on “N Likes” in Discourse. riking initially reported the issue and provided repro steps, but codinghorror and gerhard were unable to reproduce it. However, riking and codinghorror later found that the issue can be reproduced by clicking on the link and expanding likes twice.
eviltrout investigated the issue and suspected it to be a Chrome bug, as it doesn’t occur in Safari or Firefox. The issue appears to be related to changing the innerHTML of an element on the page after navigating back and forth. A potential workaround was suggested by sam through a commit on GitHub, although it’s not ideal and may require further amendment with the DOM diffing feature.
I just spent over an hour on this and I am still confused.
I am 99% sure at this point it’s a bug in Chrome, although I can’t find anyone else on the web reporting it. It seems that:
If you visit a topic page
Hit the back button
Go forward into a topic (needn’t be the same)
Adjust the innerHTML of any element on the page
Then the page will scroll randomly (usually upwards).
This only happens in Chrome for me, not Safari or Firefox. I used the Javascript debugger to isolate it down to a single innerHTML change, so it’s not jQuery. In fact, I can cause it outside of an event loop such as ember by just running a command like document.getElementById('post_25').innerHTML = 'hello'
I’m not sure how to proceed here – perhaps it will just be fixed shortly in Chrome? To make a bug report for them would involve tearing away many parts of Discourse until we could isolate it.