Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll position jumps when editor is inside of wrapper div #2166

Closed
zokioki opened this issue Jun 22, 2018 · 16 comments · Fixed by #3840
Closed

Scroll position jumps when editor is inside of wrapper div #2166

zokioki opened this issue Jun 22, 2018 · 16 comments · Fixed by #3840

Comments

@zokioki
Copy link

zokioki commented Jun 22, 2018

Currently working on a project using Quill where we would like to have the toolbar be sticky as the user scrolls down the page (this provides a great experience for editing longer articles on both mobile and desktop).

The issue we've run into is that if the editor is wrapped inside another div, the scroll position jumps when editing the content, no matter how we configure the scrollingContainer:

quill-sticky-toolbar-example

Steps for Reproduction

The following pens were branched off the Auto-grow height example from Quill's playground

  • Setting scrollingContainer to a dedicated #scrolling-container element:

    • Visit https://codepen.io/coxandrew/pen/pKKvNj
    • Scroll down to the "Scroll down below this header" header
    • Select some text and make it a link
    • After you click "save", the scroll position will jump all the way to the top
  • Setting scrollingContainer to html:

  • Works fine when editor is not wrapped inside a div:

Expected behavior:

Expected to not cause scroll position to jump when editor is inside a wrapper div and edits are performed.

Actual behavior:

Scroll position jumps up when scrollingContainer is set to a dedicated element, and down when set to html.

Platforms:

Browser Operating System
Chrome 67.0.3396.87 (Official Build - 64-bit) macOS 10.13.5 (High Sierra)

Version:

1.3.6

@zokioki
Copy link
Author

zokioki commented Jun 22, 2018

CC @coxandrew

@wmdmark
Copy link

wmdmark commented Aug 13, 2018

Bump... I have the same issue. Any work-arounds for this?

@RyanV
Copy link
Contributor

RyanV commented Aug 14, 2018

I can't reproduce this with the scrollingContainer set to html. It seems to function as expected.

tested with your codepen + Chrome Version 68.0.3440.106

@goggalore
Copy link

Yep, still experiencing this in 2019. Only happens when the editor is contained in a wrapper. Guess the workaround is not to use a wrapper, though this limits the ability to use something like a flexbox to contain the editor and toolbar, for example.
Any updates?

@li2go
Copy link

li2go commented Aug 1, 2019

Currently working on a project using Quill where we would like to have the toolbar be sticky as the user scrolls down the page (this provides a great experience for editing longer articles on both mobile and desktop).

The issue we've run into is that if the editor is wrapped inside another div, the scroll position jumps when editing the content, no matter how we configure the scrollingContainer:

quill-sticky-toolbar-example

Steps for Reproduction

The following pens were branched off the Auto-grow height example from Quill's playground

  • Setting scrollingContainer to a dedicated #scrolling-container element:

    • Visit https://codepen.io/coxandrew/pen/pKKvNj
    • Scroll down to the "Scroll down below this header" header
    • Select some text and make it a link
    • After you click "save", the scroll position will jump all the way to the top
  • Setting scrollingContainer to html:

  • Works fine when editor is not wrapped inside a div:

Expected behavior:

Expected to not cause scroll position to jump when editor is inside a wrapper div and edits are performed.

Actual behavior:

Scroll position jumps up when scrollingContainer is set to a dedicated element, and down when set to html.

Platforms:

Browser Operating System
Chrome 67.0.3396.87 (Official Build - 64-bit) macOS 10.13.5 (High Sierra)
Version:

1.3.6

i have same problem

@vinitpradhn18
Copy link

Does anyone have a fix for this, yet?

@ImLuckyJr
Copy link

You can try it https://stackoverflow.com/a/45823484

@itsmhuang
Copy link

Having this issue as well. Setting scrollingContainer to html or wrapping div behaves the same: scroll jumps to top and back down.

@Doidel
Copy link

Doidel commented Dec 31, 2019

I have the same issue. Any updates?

@tsalmeida
Copy link

For anyone looking for a solution, I got it fixed by setting scrollingContainer to 'html'. My problem was caused by setting the toolbar to 'position: sticky', so that it would be always visible.

@edwardcahyadi
Copy link

Facing the same issue, not being able to wrap the editor in a div is a big deal imo...

@Doidel
Copy link

Doidel commented Jan 14, 2020

But you can. The workaround on StackOverflow posted by ImLuckyJr helped me:

componentDidMount()
{
$('.quill-toolbar').on("mousedown", function(event){
event.preventDefault();
event.stopPropagation();
});
}

@nazarposhta
Copy link

@Doidel looks like it works

@TristanJanicki
Copy link

If anyone is looking for a fix for this you can record the last selection range before your action that causes the scroll and then do quill.setSelection(index, length) and that fixes it (except the scroll is slightly off as it makes the selected text be the bottom of the scroll not say the middle)

@yasiinakbulut58
Copy link

But you can. The workaround on StackOverflow posted by ImLuckyJr helped me:

componentDidMount()
{
$('.quill-toolbar').on("mousedown", function(event){
event.preventDefault();
event.stopPropagation();
});
}

this works but not for ql-tooltip (link, video, image..)

@akkayaburak
Copy link

this works but not for ql-tooltip (link, video, image..)

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.