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.

ql-align html tag in custom toolbar throw error

See original GitHub issue

I want to create a custom toolbar in HTML, but when I add ql-align tag, I got this error:

TypeError: Cannot read property 'innerHTML' of null
    at IconPicker.selectItem (quill.js:9693)
    at new IconPicker (quill.js:9684)
    at quill.js:6739
    at Array.map (<anonymous>)
    at SnowTheme.buildPickers (quill.js:6734)
    at SnowTheme.extendToolbar (quill.js:9851)
    at SnowTheme.addModule (quill.js:6703)
    at quill.js:6049
    at Array.forEach (<anonymous>)
    at SnowTheme.init (quill.js:6047)

Steps for Reproduction

code in html:

<select class="ql-align" />

Platforms: Chrome 68 on Mac 10.12.6

Version: “quill”: “^1.3.6”

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
jvnlwncommented, Aug 9, 2021

Ran into this error when using react-quill (version 1.3.5, quill version 1.3.7).

In my case, it was occurring when rendering multiple quill editors each with their own custom toolbar.

const QuillEditor = () => (
  <>
    <div className="toolbar">
      <select className="ql-align" />
    </div>
    <ReactQuill modules={{ toolbar: ".toolbar" }} />
  </>
)

const App = () => (
  <>
    <QuillEditor />
    <QuillEditor />
  </>
)

Rendering <App /> will fail with the error Unhandled Rejection (TypeError): Cannot read property 'innerHTML' of null

Without the custom toolbar, the error is resolved:

const QuillEditor = () => (
  <ReactQuill modules={{ toolbar: [[{ align: [] }]] }} />
)

To fix the issue in my case, the solution was to provide a unique className to the toolbar:

const QuillEditor = ({ className }) => (
  <>
    <div className={`toolbar ${className}`}>
      <select className="ql-align" />
    </div>
    <ReactQuill modules={{ toolbar: `.${className}` }} />
  </>
)

const App = () => (
  <>
    <QuillEditor className="test-1" />
    <QuillEditor className="test-2" />
  </>
)

And in my real-world case, I elected to generate a unique className on the fly when the component mounts, this way I don’t have to supply one whenever I render the component.

NOTE: Ideally, quill would allow you to alternatively provide the actual HTML node as the container. That would remove the need for unique classNames or IDs. Maybe this is already possible? But it did not seem to work when I tried.

1reaction
LeonPrucommented, Jul 20, 2019

Facing the same issue. Would love to know how you “rendered again”. @Heyxuxiaoting

Read more comments on GitHub >

github_iconTop Results From Across the Web

quill error 'quill Invalid Quill container' - Stack Overflow
The problem was that Quill was initiated before the DOM container element was properly rendered. If you can make it sure (use a...
Read more >
JS Error in text editor with custom toolbar item | Blazor Forums
The first editor is working well, but the last is throwing this js errors and i cant remove or edit the content well....
Read more >
ngx-quill - npm
Using all is not recommended, it cause some unexpected sideeffects. Full Quill Toolbar HTML. Global Config. It is possible to set custom default ......
Read more >
Controlled Example with Custom Toolbar (React 16.3.0)
In CodePen, whatever you write in the HTML editor is what goes within the <body> tags in a basic HTML5 template. So you...
Read more >
Creating Reusable Custom Blazor Controls
Features Of The Blazor Quill Rich Text Editor Custom Control · Exports editor contents in Text, HTML, and Quill's native Delta format ·...
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