Page jumps after clicking N Likes

Repro steps:

  1. Click here: Add new metrics in the administration interface
  2. Click on 3 Likes
  3. Press the back button
  4. Click the link again
  5. Click 3 Likes again
  6. Viewport should jump either up or down, causing more posts to load in and wrecking your read position
3 Likes

Actually that does not repro for me, perhaps because I opened the link in a new window?

Nope, does not repro for me by clicking on the link here in this window either…

Yes, this only happens when the link is opened in the same tab (just tested on Chrome/Windows).
Weird, now it’s not happening anymore… :confused:

2 Likes

If it doesn’t work, press back and try again.

2 Likes

Aha so the proper repro is to do this twice:

  1. Click on the link
  2. Click to expand likes
  3. Click back
  4. Click on the link (again)
  5. Click to expand likes

Then I do indeed get the jumping behavior cc @eviltrout

2 Likes

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.

6 Likes

I worked around this issue, successfully with:

https://github.com/discourse/discourse/commit/c3f08145b808dada9244194e0ea1ab55bff22f12

It’s not ideal but rerender is kind of rare and we may be amending this a bit with the DOM diffing.

5 Likes