Fix deletion issues when using Chromium Android #5644
Merged
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.
Because
preventDefault
doesn't actually do anything on thebeforeinput
event on Chromium Android,deleteContentBackward
will actually delete things twice, once by Lexical and once by the browser. This is the cause of issues like #4941 and #5538.The issue with backspace deleting two characters at once was patched in #5077 by pretending to be in composition mode so that the else statement with the
DELETE_CHARACTER_COMMAND
line wouldn't be triggered. This patched the issue but in turn caused issues #5274 and #5259.#5274 was fixed in #5282 by adding new logic to actually trigger the
DELETE_CHARACTER_COMMAND
if the current node had the length<= 1
. #5259 was fixed in #5389 by resetting the compositionKey if the keys of the anchor and focus nodes is different.The changes in this PR were originally made to fix #5538, but I realized that it also fixes the other Chromium Android deletion issues. Doing it this way, we don't have to pretend to be in composition mode and the code is also more clear about why that logic is required.