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.

Error: The given range isn't in document

See original GitHub issue

I noticed an annoying The given range isn't in document error during text editing in Chrome. I found one way to reproduce the problem in the Quill demo on your website so I guess this means this is a problem in Quill and not in my code.

Steps for Reproduction

  1. Visit quilljs.com and switch to the third demo (The one where you can set a text color).
  2. Click into the text area to focus the editor.
  3. Select all text with Ctrl-A.
  4. Remove selected text with Del. The document must be completely empty now.
  5. Select a text color with the color picker in the toolbar.
  6. Type multiple lines of text (Can’t be reproduced with just one line).
  7. Select all content again with Ctrl-A.
  8. Type new text.

Expected behavior:

The new text must replace the selected text.

Actual behavior:

The selected text is removed, the error message The given range isn't in document is thrown and the editor looses the focus.

Platforms: Chrome 63.0.3239.132 on Debian Linux 9.3

Version: 1.3.5

screenshot from 2018-02-03 01-19-08

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:14
  • Comments:51 (1 by maintainers)

github_iconTop GitHub Comments

117reactions
HeGanjiecommented, Apr 8, 2018

I solve this issue by caching the modules props, instead of keep creating a new instance during each render.

Before:

<ReactQuill
        modules={{...}}
        ...
      />

After:

<ReactQuill
        modules={this.modules}
        ...
      />
44reactions
rw3isscommented, Dec 19, 2018

Had the same problem and fixed it by not using the ‘value’ prop on the editor, but rather the ‘defaultValue’, which is apparently unmanaged to some extent. Using ‘react-quill’, fyi. Hope it helps.

 <ReactQuill 
            theme={'snow'}
            onChange={this.props.onChange}
            defaultValue={this.state.text}
            modules={ReactQuillEditor.modules}
            formats={ReactQuillEditor.formats}
            placeholder={'Write something...'}
        />
Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Quill - addRange(): The given range isn't in document
I was able to solve it by updating the value of value to editor.getContents() inside the onChange callback, which is called back with...
Read more >
Fab Follow - CodePen
Quill Playground : The given range isn't in document issue (https://github.com/quilljs/quill/issues/1134) · Fab Follow. Love Run. Pen Editor Menu. Settings ...
Read more >
The given range isn't in document - Atlassian Community
The given range isn't in document ... Looks like when cursor focus not on the editor, it could not get the range from...
Read more >
React-Quill - addRange(): The given range isn't in document ...
[Solved]-React-Quill - addRange(): The given range isn't in document-Reactjs. use literal object as modules props, it will trigger component rerender , use ...
Read more >
react quill gains focus on hover - Knovigator
upgrading to react-quill@beta caused the addRange errors. Gravatar for undefined ... Error: The given range isn't in document · Issue #1940 · quilljs/quill....
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