fix(block-events): caret losing after backspace after nested list #2723
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Pressing backspace at the start of a paragraph after a Nested List causes the caret to be lost.
caret-bug.mov
Cause
There are two problems:
The backspace handler incorrectly shows
true
forareBlockMergeable()
. This was due to confused arguments: the first argument is the block to merge into, and the second is the block to merge from. After fixing this,areBlockMergeable()
will returnfalse
.The Nested List tool has a
conversionConfig
but lacks amerge()
method, making it not mergeable. This case was not covered by tests, so I've added the corresponding test case.During debugging, I noticed that creating/restoring the Shadow caret did not work for Nested Lists. Previously, it added a Shadow caret to
pluginContent
, which is complex for Nested Lists, and it was added to a wrong place.Solution
areBlockMergeable()
.createShadow()
frompluginContent
tolastInput
, so the shadow caret is now set properly. Although with the fix №1 this logic won't be called, but I've fixed it anyway.caret-bug-fixed.mov
And then I'm gonna update the Nested List tool adding a
merge()
method in there. After that the merging will start working instead of caret moving.