RichText: fix caret position when deleting a selected word #11965
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.
Description
Fixes #11964 and adds e2e tests.
Also fixes an issue where CTRL+A wouldn't select all blocks if you first select all text in a rich text field by triple clicking and then pressing CTRL+A.
In #11627 I retained deletion handling for uncollapsed selections (meaning text is selected) because I couldn't figure out the problem fast enough with letting it be handled natively again. It turns out TinyMCE is handling the case where an instance is entirely selected, and the React
onKeyDown
event is only fired after the TinyMCE event, causing TinyMCE to delete the contents first, and then us thinking the field is empty and merging it with the neighbouring block. The solution is to prevent the TinyMCE behaviour in that case, and handle it ourselves.@notnownikki I also updated the tests you have added, to check if the space is actually there before retyping.
How has this been tested?
See #11964 and above.
Screenshots
Types of changes
Checklist: