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: When using Gboard on Android, doing "Select all" then deleting the text doesn't seem to correctly stop the select all action #5259

Closed
amanharwara opened this issue Nov 20, 2023 · 4 comments · Fixed by #5389

Comments

@amanharwara
Copy link
Contributor

Lexical version: 0.12.4

Steps To Reproduce

  1. Open the playground on an Android browser (I've tested on both Chrome and Firefox)
  2. Make sure you're using Gboard as the keyboard
  3. "Select all" text
  4. Delete the text using the backspace button in Gboard

Link to code example: https://playground.lexical.dev

The current behavior

Once you "Select all" and delete the text, the text will correctly get deleted. However, if you start typing again, you'll notice that the select all action doesn't seem to have stopped and as you keep typing all the text will keep getting selected and replaced by the next character, making it very hard to actually type more than a character.

Here's a screen recording of the behavior:

Screen_Recording_20231120_214539_Brave.mp4

The expected behavior

Once you delete all the text selected using the "Select all" action, it should stop automatically selecting text when you start typing again.

Additional context

This issue seems to only happen when using Gboard and not other keyboards. I tested with Samsung Keyboard as well.
Also, this issue is not present in v0.12.2 or earlier.

@acywatson
Copy link
Contributor

@zurfyx @GermanJablo

insertNodes?

@amanharwara
Copy link
Contributor Author

@acywatson a good ol' git bisect brought me to this change: ca45b1d#diff-13ea778ff524191baf03fce4f1a86503d50f068ef5e14bd4e064a1fd69fcf054R519-R521

Commenting out that code does seem to fix this particular issue, but it looks like that code is required for the Android backspace bug fix.

@amanharwara
Copy link
Contributor Author

Hmm, tried something out and it looks like doing $setCompositionKey(null) in this else block here https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalEvents.ts#L560 fixes this while also not breaking backspace on Android. I'll open a PR.

@amanharwara
Copy link
Contributor Author

Looks like this wasn't just an issue with "Select all" but with any selection where the anchor.key and focus.key were different.

Opened a PR #5389 with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants