Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM mutations suppress selection-change event #3563

Closed
luin opened this issue Apr 15, 2022 · 0 comments · Fixed by #3591
Closed

DOM mutations suppress selection-change event #3563

luin opened this issue Apr 15, 2022 · 0 comments · Fixed by #3591

Comments

@luin
Copy link
Member

luin commented Apr 15, 2022

We notice when DOM mutations are made inside the handler of document's selectionchange event synchronously, Quill won't fire a selection-change event.

Steps for Reproduction

  1. Visit https://codepen.io/luin/pen/OJzBGXM
  2. Open the dev tool and observe console logs.
  3. Click on "CLICK ME".
  4. Observe the logs.
  5. Click on other text.
  6. Observe the logs.
CleanShot.2022-04-15.at.17.12.59.mp4

Expected behavior:
Each click should trigger a selection-change log.

Actual behavior:
Nothing is logged.

Platforms:

Chrome, Firefox, and Safari.

Version: 2.0 beta

The breakdown of what happened:

  1. When clicking on "CLICK ME", a mutation of adding a class to the "CLICK ME" node is made.
  2. Scroll#update is triggered, and https://github.com/quilljs/quill/blob/b212f9eaea7c12efb255830f45edb41a2addb5b6/core/selection.js#L53 selection is updated silently as a result of the mutation.
  3. On mouse up, Quill calls selection.update('user'), but nothing happens as the selection is already updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant