# Page jumps after clicking N Likes

**URL:** <https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238>\
**Category:** Bug\
**Created:** [2015年九月14日 19:00 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238 "2015-09-14T19:00:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [2015年九月14日 19:00 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238/1 "2015-09-14T19:00:34Z")

</div>

Repro steps:

1. Click here: [Add new metrics in the administration interface - #15 by riking](https://meta.discourse.org/t/add-new-metrics-in-the-administration-interface/15179/15)
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

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2015年九月14日 19:59 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238/2 "2015-09-14T19:59:52Z")

</div>

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..

---

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [2015年九月14日 20:01 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238/3 "2015-09-14T20:01:35Z")

</div>

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… 😕

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [2015年九月14日 20:07 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238/4 "2015-09-14T20:07:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2015年九月14日 20:08 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238/5 "2015-09-14T20:08:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [2015年九月16日 20:59 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238/6 "2015-09-16T20:59:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2015年十二月17日 06:41 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238/7 "2015-12-17T06:41:14Z")

</div>

I worked around this issue, successfully with:

[https://github.com/discourse/discourse/commit/c3f08145b808dada9244194e0ea1ab55bff22f12](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.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2015年十二月17日 06:41 UTC](https://meta.discourse.org/t/page-jumps-after-clicking-n-likes/33238/8 "2015-12-17T06:41:51Z")

</div>


