quill
quill copied to clipboard
Custom toolbar: buttons mouse clicks get broken if Quill is re-instantiated
When Quill editor with a custom toolbar is re-instantiated, toolbar buttons get new event listeners added on top of each other, breaking mouse click behaviour.
In our setup, modules need to be updated based on user preferences, which requires re-instantiating Quill, afaik. I opened #4234 to check if it can be avoided, but this current issue seems like a separate bug.
My guess is that since these listeners are added as anonymous functions they are added each time editor is instantiated, rather than being ignored (reference)
Steps for Reproduction
Here's a demo
https://github.com/slab/quill/assets/34838167/ebf4de7c-a2d0-4e34-ba4e-063bbdcfae91
- Visit quilljs playground
- Click "Re-create" button
- Try to mouse-click any formatting button in toolbar
- Check event listeners in dev tools
Expected behavior: Format buttons work as usual
Actual behavior: Format buttons can't be toggled
Platforms: Chrome 125.0.6422.141, MacOS
Version: 2.0.2