question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scroll position jumps when editor is inside of wrapper div

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:17
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Doidelcommented, 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(); }); }

2reactions
tsalmeidacommented, Jan 7, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content Jumping (and How To Avoid It) | CSS-Tricks
To fix it, I used the browser's DevTools to measure the height of the resulting content and hardcoded it as a min-height for...
Read more >
Scroll position affected by internal layout changes inside a ...
The basic rule is: If the css box of a child element of the scroll content changes its height and currently intersects the...
Read more >
Guide to scroll anchoring - CSS: Cascading Style Sheets | MDN
Scroll anchoring adjusts the scroll position to compensate for the changes outside of the viewport. This means that the point in the document ......
Read more >
Prototype scrolling with overflow behavior - Figma Help Center
If you change the bounds of the frame so that all the content fits inside it, ... Preserve scroll position allows you to...
Read more >
position: sticky is Amazing - Mastery Games
Don't try to use overflow: auto|scroll|hidden on the parent element of a position:sticky element. It completely breaks the stickiness. overflow: visible is fine ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found