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

Fix deletion issues when using Chromium Android #5644

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

amanharwara
Copy link
Contributor

Because preventDefault doesn't actually do anything on the beforeinput 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.

Copy link

vercel bot commented Feb 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2024 7:35pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2024 7:35pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 21, 2024
Copy link
Contributor

@acywatson acywatson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues here. @zurfyx ?

@quanvan1999
Copy link

There are numerous problems with Android. Can you merge the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Choosing word suggestion on Android will sometimes delete parts or whole of the next word
4 participants