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

Bug: editor.onChange is not triggered in case of removing the whole text inside block, if the contenteditable element is not the root node of a block #2523

Closed
VikhorKonstantin opened this issue Oct 27, 2023 · 0 comments · Fixed by #2639

Comments

@VikhorKonstantin
Copy link
Contributor

VikhorKonstantin commented Oct 27, 2023

if (target === element) {
-
this check won't help if the change happened within some descendant of the 'element'.

For example, if we remove the text inside one of the 'li' items of '@editorjs/nested-list' block, onChange won't be triggered.

neSpecc added a commit that referenced this issue Feb 28, 2024
* fix isMutationBelongsToElement function: make it return true if the whole text node is deleted inside of some descendant of the passed element

* isMutationBelongsToElement function shouldn't return true if some of the ancestors of the passed element were added or deleted, only if the element itself

* add test case verifying that 'onChange' is fired when the whole text inside some nested  descendant of the block is removed

* replace introduced dependency with ToolMock

* add comment explaining isMutationBelongsToElement behaviour in case of adding/removing the passed element itself

* fix formatting

* added some more explanation

* added record to the changelog

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
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