# Oneboxed Google Docs break scroll position

**URL:** https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919
**Category:** Bug
**Created:** [May 17, 2015, 6:11pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919 "2015-05-17T18:11:54Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Mikulas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikulas/32/104867_2.png) [@Mikulas](https://meta.discourse.org/u/Mikulas)
#### Post date: [May 17, 2015, 6:11pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/1 "2015-05-17T18:11:54Z")

</div>

It seems that embedding Google docs results in a page scrolling automatically to top.

I was only able to reproduce this on all latest browsers on Yosemite. It does not happen always (but still in a majority of tries) and seems to be based on how quickly the embedded content loads.

Steps to repro:

1. create a post below the page fold with a link to Google spreadsheet
2. get the persistent link to the post and open the page
3. the page should load and be correctly scrolled (embedded content not loaded yet)
4. embedded content loads and another scroll is triggered

What should happen is the page should be scrolled to correct position.  
Instead the page is scrolled to the top of the page currently loaded (not the first post if the thread is long).

Demo: open in new tab, clicking it would not result in reload and the bug would not trigger

```
https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/2

```

---

<div class="post-metadata">

### Author: ![Mikulas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikulas/32/104867_2.png) [@Mikulas](https://meta.discourse.org/u/Mikulas)
#### Post date: [May 17, 2015, 6:13pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/2 "2015-05-17T18:13:23Z")

</div>

Test case:

> – making sure this thread is tall enough  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –  
> –

> **[Scroll issue onebox](https://docs.google.com/spreadsheets/d/1rudZZUDZjnCSThFCggNqDoZ14PIUBEId2YacRBDVOzo/edit?usp=sharing)**
>
> This Sheet is private

---

<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: [May 17, 2015, 8:39pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/3 "2015-05-17T20:39:02Z")

</div>

Yes, any embed that has variable height will completely screw up positioning in the stream. There is no way around this unless the embed has a guaranteed height.

---

<div class="post-metadata">

### Author: ![Mikulas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikulas/32/104867_2.png) [@Mikulas](https://meta.discourse.org/u/Mikulas)
#### Post date: [May 18, 2015, 7:49am UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/4 "2015-05-18T07:49:12Z")

</div>

Fair enough, but I’d say the original scroll position is correct; why is a second scroll called when onebox loads? Omitting the second scroll would solve this particular issue of random scroll to the top of the page, wouldn’t 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: [May 18, 2015, 7:50am UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/5 "2015-05-18T07:50:07Z")

</div>

Because we are at war with the web browser especially when you hit the back button

---

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [May 30, 2016, 6:27pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/6 "2016-05-30T18:27:53Z")

</div>

> [@codinghorror](#):
>
> Yes, any embed that has variable height will completely screw up positioning in the stream. There is no way around this unless the embed has a guaranteed height.

This bug is pretty annoying. I’m somewhat motivated to help fix it. Is there any reason for the Google Docs onebox _not_ to have a fixed height?

---

<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: [May 30, 2016, 6:30pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/7 "2016-05-30T18:30:25Z")

</div>

No idea, depends on the embed api. We found that Twitter did return the size of images in tweets so that became possible. Size of embed is critical to us. Variable height embeds are a total no-go in the post stream; they have catastrophic, and cascading effects.

---

<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: [August 9, 2016, 9:27pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/8 "2016-08-09T21:27:51Z")

</div>

We need to remove this embedding in favor of a simple link to the document as previously discussed @techapj. Can you try to get to that, this week?

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [August 10, 2016, 2:37pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/9 "2016-08-10T14:37:17Z")

</div>

Done via:

[https://github.com/discourse/onebox/commit/1e71bd9daa1e4fd9678b60e477bd17bdaf674f7b](https://github.com/discourse/onebox/commit/1e71bd9daa1e4fd9678b60e477bd17bdaf674f7b)

and

[https://github.com/discourse/discourse/commit/d65f7742a76be4d8f66697865034ac6a4c366e9e](https://github.com/discourse/discourse/commit/d65f7742a76be4d8f66697865034ac6a4c366e9e)

Demo oneboxes here:

> [@Google docs onebox gem requires a "published" document](https://meta.discourse.org/t/google-docs-onebox-gem-requires-a-published-document/33649/17):
>
> Okay, this is now done. Sheet: [https://docs.google.com/spreadsheets/d/1FdgO2IrP99W4KtE2ImtEVE-qMHNFai5MyeKxZFv04oc/edit?usp=sharing](https://docs.google.com/spreadsheets/d/1FdgO2IrP99W4KtE2ImtEVE-qMHNFai5MyeKxZFv04oc/edit?usp=sharing) Document: Form: Slide:

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [August 10, 2016, 2:37pm UTC](https://meta.discourse.org/t/oneboxed-google-docs-break-scroll-position/28919/10 "2016-08-10T14:37:55Z")

</div>


