# Prosemirror is causing a scroll to the whole page

**URL:** <https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486>\
**Category:** Uncategorized\
**Created:** [November 9, 2016, 4:05pm UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486 "2016-11-09T16:05:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![erwanl](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/erwanl/32/221_2.png) [@erwanl](https://discuss.prosemirror.net/u/erwanl)\
**Post date:** [November 9, 2016, 4:05pm UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486/1 "2016-11-09T16:05:36Z")

</div>

Hi,

The way my page works is:

- I have a (fixed) sidebar on the left, a (fixed) topbar, and a (vertical) scroller div in the middle
- I have many blocks in my scroller div, including Prosemirror editor(s)

The problem I have is that when a part of an editor is not visible, if I move the cursor down Prosemirror it will scroll many elements that I don’t want to move, ending up in my topbar becoming hidden.

I don’t want the editors to have a fixed height and a vertical scroll either, because that would give me a double-scrollbar. So what I want (and it’s what I have already) is editors with a size automatically adapting according to the height of the content.

Apparently this is the method responsible for the scroll: [https://github.com/ProseMirror/prosemirror-view/blob/master/src/dompos.js#L160](https://github.com/ProseMirror/prosemirror-view/blob/master/src/dompos.js#L160)

It doesn’t seem to have any stop condition, and will scroll to the root of the DOM, is that correct? Is there a way to specify a node as responsible for the scroll so scrolling stays within that node?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 10, 2016, 4:24pm UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486/2 "2016-11-10T16:24:38Z")

</div>

I tried to reproduce this by wrapping a ProseMirror editor in a scrollable div and making sure the outer page is scrollable, but I couldn’t – when I move the cursor out of view, only the inner div scrolls, not the the outer page.

Could you provide me with a (minimal, simple) HTML example that reproduces the issue?

---

<div class="post-metadata">

**Author:** ![erwanl](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/erwanl/32/221_2.png) [@erwanl](https://discuss.prosemirror.net/u/erwanl)\
**Post date:** [November 10, 2016, 4:45pm UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486/3 "2016-11-10T16:45:40Z")

</div>

OK, currently it’s in a big page so I’ll try to reproduce in a small case.

---

<div class="post-metadata">

**Author:** ![erwanl](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/erwanl/32/221_2.png) [@erwanl](https://discuss.prosemirror.net/u/erwanl)\
**Post date:** [November 14, 2016, 2:14pm UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486/4 "2016-11-14T14:14:54Z")

</div>

Hi Marijn,

I have a simple repro case here:

- demo: [https://rawgit.com/erwan/prosemirror-scroll-bug/master/index.html](https://rawgit.com/erwan/prosemirror-scroll-bug/master/index.html)
- source: [https://github.com/erwan/prosemirror-scroll-bug](https://github.com/erwan/prosemirror-scroll-bug)

I forked the demo page so I won’t have to setup a build system.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 15, 2016, 10:28am UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486/5 "2016-11-15T10:28:20Z")

</div>

Your page creates a situation where the cursor ends up outside the visible part of an overflow: hidden element. I think the solution is to adjust it so that that doesn’t happen (in the demo, somehow style the editor-wrapper element to not extend beyond the bottom of the window), since even if ProseMirror refrained from scrolling your element here, you’d end up with an unusable editor when the cursor becomes invisible.

---

<div class="post-metadata">

**Author:** ![erwanl](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/erwanl/32/221_2.png) [@erwanl](https://discuss.prosemirror.net/u/erwanl)\
**Post date:** [November 15, 2016, 12:28pm UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486/6 "2016-11-15T12:28:35Z")

</div>

Thank you!

Do you have an example of fixed header/scrollable content that is compatible with prosemirror?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 15, 2016, 12:40pm UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486/7 "2016-11-15T12:40:30Z")

</div>

Just make sure the scrollable container is itself entirely visible. I.e. in your demo, the scrollbar on the inner container goes off the bottom of the page (might be harder to see on platforms that hide scrollbars). That’s the problem.

---

<div class="post-metadata">

**Author:** ![erwanl](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/erwanl/32/221_2.png) [@erwanl](https://discuss.prosemirror.net/u/erwanl)\
**Post date:** [November 15, 2016, 2:16pm UTC](https://discuss.prosemirror.net/t/prosemirror-is-causing-a-scroll-to-the-whole-page/486/8 "2016-11-15T14:16:35Z")

</div>

Actually after testing with content editable, without prosemirror I have the same issue! So the scroll is not caused by prosemirror, it behaves this way with a vanilla contenteditable.

So nothing to do with prosemirror, sorry for that 🙂
