wobsoriano / lexical-vue

An extensible Vue 3 web text-editor based on Lexical.
https://lexical-vue.vercel.app/
MIT License
251 stars 30 forks source link

Move checklist listener management to helper to prevent duplicate events #20

Closed zswaff closed 1 year ago

zswaff commented 1 year ago

Background

As it stands now, making multiple instances of <LexicalCheckListPlugin> (e.g. with two editors on one page) will instantiate separate instances of let listenersCount = 0 and therefore both (or all) of the editors will separately register document-level event listeners for click and pointerDown.

Repro

Make an even number of editors in one page, each with the checklist plugin. An even number of listeners are registered on the document. When a checkbox is clicked an even number of handeClicks are fired and the checkbox is toggled an even number of times. From a user's perspective the box does not change on click.

Notes

Does the fix make sense and work? This was the best fix I found but happy to implement a different way if preferable.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 5, 2023 1:11am
lexical-vue-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 5, 2023 1:11am
wobsoriano commented 1 year ago

Thank you!