quill icon indicating copy to clipboard operation
quill copied to clipboard

Custom toolbar: buttons mouse clicks get broken if Quill is re-instantiated

Open ViktorZhurbin opened this issue 8 months ago • 3 comments

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

  1. Visit quilljs playground
  2. Click "Re-create" button
  3. Try to mouse-click any formatting button in toolbar
  4. 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

ViktorZhurbin avatar Jun 04 '24 14:06 ViktorZhurbin