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.

RichTextEditor image upload (Cannot read properties of null (reading 'index'))

See original GitHub issue

What package has an issue

@mantine/rte

Describe the bug

  1. Wrap react app in a Strict Mode component.
  2. Add a RichTextEditor component.
  3. Add an image via the embed image icon in the toolbar: image
  4. You should see the error Cannot read properties of null (reading 'index')

Drag/drop works, pasting works, just the toolbar is causing this error (when wrapped in <StrictMode>).

In which browser did the problem occur

Chrome

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/s/bold-field-ilkjez?file=/src/App.js

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

No response

Possible fix

Looks like this.range is reset in the ImageUploader in strict mode.

I could be wrong (and I haven’t tested this) but I think we might want to set the range here via this.range = this.quill.getSelection();.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rtivitalcommented, Jul 31, 2022

The issue happens only in with react strict mode, disable strict mode to fix it. The issue cannot currently be resolved on library side.

0reactions
wes337commented, May 30, 2022

I’m still have this error on almost all of toolbar button: lists, image… And “addRange(): The given range isn’t in document.” on other toolbar buttons.

I’m seeing it on lists too. But it is fixed with images, just make sure you’re using at least version 4.2.7

But everything else is fine. What do you mean when you say “almost all of the toolbar button”? I’m also seeing the “index is null” error, and not “addRange()”. Could we be talking about different issues?

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ask Question
TypeError : Cannot read properties of null (reading 'index'). I'm using the code given in official documentation here.
Read more >
Rich text editor is throwing error in AEM 6.4 when...
Error message - Uncaught (in promise) TypeError: Cannot read properties of null (reading 'data') - http://localhost:4502/libs/cq/gui/components/ ...
Read more >
Cannot read property 'querySelector' of null for rich text ...
Forum Thread - Cannot read property 'querySelector' of null for rich text editor when i resizing the screen. - Angular - EJ 2....
Read more >
Rich text editor
Quill based rich text editor. ... experience the following error if strict mode is enabled: TypeError: Cannot read properties of null (reading 'index')...
Read more >
Building A Rich Text Editor (WYSIWYG)
Let's build a rich text, WYSIWYG-editor that supports rich text, images, links and some nuanced features from word processing apps.
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