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

The body jump scroll position if you click between multiple quill editors #855

Closed
sferoze opened this issue Aug 10, 2016 · 7 comments
Closed

Comments

@sferoze
Copy link
Contributor

sferoze commented Aug 10, 2016

If you have multiple quill editors on the same page, when you click from one editor to the other it makes the body jump scroll position. It does not always do this, but 50% of the clicks from one editor to another makes the body scroll.

Steps for Reproduction

I will update with reproduction of the issue

Expected behavior: The body should not scroll by simple clicking in the editor. Why does the editor even affect the body scroll position? Is this some feature? Can I turn it off?

Platforms: Chrome on Mac

@sferoze
Copy link
Contributor Author

sferoze commented Aug 10, 2016

This update fixes it

64841e3?diff=split

@sferoze
Copy link
Contributor Author

sferoze commented Aug 10, 2016

Im curious why even have this code? What's the purpose of it? Why should the editor ever control the scroll position of the body?

        let scrollTop;
        this.root.addEventListener('blur', () => {
          scrollTop = this.root.scrollTop;
        });

        this.root.addEventListener('focus', () => {
          if (scrollTop == null) return;
          this.root.scrollTop = scrollTop;
        });

@jhchen
Copy link
Member

jhchen commented Aug 11, 2016

Are you sure you included the right code snippet? This is not what the 1.0.0-beta.11 selection.js file looks like.

@sferoze
Copy link
Contributor Author

sferoze commented Aug 11, 2016

@jhchen hmm yah I got it from a commit 22 days ago. But with the newest quill beta 11

        var scrollTop = void 0,
            bodyTop = void 0;
        this.root.addEventListener('blur', function () {
          scrollTop = _this.root.scrollTop;
          bodyTop = document.body.scrollTop;
        });
        this.root.addEventListener('focus', function (event) {
          if (scrollTop == null) return;
          _this.root.scrollTop = scrollTop;
          document.body.scrollTop = bodyTop;
        });

This code make the page jump when blur and focus are triggered between editors. I am using multiple quill editors on the same page.

So I just commented that snippet of code out.

What is it for? There seems to be no issues with the editor. The way I use the quill editor, it is inline, so the editor itself never has a scrollbar, only the body of the page. The editor div can grow and shrink based on the content.

@jhchen
Copy link
Member

jhchen commented Aug 13, 2016

The reason is some browsers will incorrectly scroll the editor to the top on blur/focus. This might happen when clicking on the toolbar, interacting with link tooltip, on paste, and maybe some other interactions I'm forgetting. So this code snippet is meant to saves and restores the scroll position.

@sferoze
Copy link
Contributor Author

sferoze commented Aug 18, 2016

hmm but for me on chrome it just makes the editor jump around on focus and blur. So I removed that snippet, and everything seems to be ok.

@faoiseamh
Copy link

faoiseamh commented Aug 22, 2016

I can confirm this behavior on Chrome as well with multiple editors present using v1.0.0-rc.0

@jhchen jhchen closed this as completed in de33374 Aug 22, 2016
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

No branches or pull requests

3 participants