Skip to content

Bug: Gboard causes cursor to jump back when navigating #3538

Closed

Description

@Spencer-Sleep

Lexical version: 0.7.1

Steps To Reproduce

  1. Use an (Android?) phone with Gboard
  2. Put the cursor somewhere in the editor input that is not the end of a line
  3. Click somewhere else in the editor input

Link to code example: https://codesandbox.io/s/lexical-plain-text-example-g932e

The current behavior

When attempting to move the cursor, it jumps back to the current location immediately. Doesn't happen if the cursor is at the end of a line, doesn't happen if the keyboard is minimized.

Only happens if Gboard is enabled. Tested it on 3 different Android phones, all had the same behavior. Not sure if it happens on iOS as well.

Video example

Screen_Recording_20221212_131438_Chrome.mp4

The expected behavior

The cursor moves and stays were you put it

Activity

  1. trueadm commented on Dec 12, 2022

    @trueadm
    Collaborator

    Did this happen in earlier versions of Lexical?

  2. Spencer-Sleep commented on Dec 12, 2022

    @Spencer-Sleep
    Author

    It looks like this was introduced in 0.4.0 - it's not an issue in 0.3.11 but occurs in later versions.

  3. trueadm commented on Dec 12, 2022

    @trueadm
    Collaborator

    Thanks for that. Looking at the diff between 0.4 and 0.3.9, the one thing that stands out to me was logic around handling mousedown – which I assume might be occurring on Android when moving selection around. Specifically this:

    https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalEvents.ts#L382-L394

    I wonder if you can test locally disabling this logic (i.e. comment out that function). If that solves it, then I think the best plan of action is to switch from using the mousedown event to using the pointerdown event – which allows us to detect if the input type is mouse or touch (this logic is only meant for mouse users I believe).

    cc @zurfyx this might be a regression introduced in #2901.

  4. thegreatercurve commented on Dec 12, 2022

    @thegreatercurve
    Contributor

    This seems to be a Chromium specific bug. Tested on Firefox on Android and it works fine.

  5. trueadm commented on Dec 12, 2022

    @trueadm
    Collaborator

    @thegreatercurve if you make the change I mention above and comment out that function, does it resolve the problem?

  6. Spencer-Sleep commented on Dec 12, 2022

    @Spencer-Sleep
    Author

    @trueadm removing that event handler does fix the issue

  7. thegreatercurve commented on Dec 12, 2022

    @thegreatercurve
    Contributor

    @thegreatercurve if you make the change I mention above and comment out that function, does it resolve the problem?

    @trueadm It does indeed! Need to check for the pointerType as well, as pointerdown fires on mobile as well.

    #3541 should close the issue.

  8. reymon359 commented on Mar 27, 2023

    @reymon359

    Hey there 👋🏽

    I am facing a very similar issue in my app, and I am using version "lexical": "0.7.6"

    when I click in the end of a word/line, it jumps to the beginning of it

    Here is an example with the lexical playground

    video5838997340148469461.mp4

    I am using a Google Pixel android phone with Gboard

    Do you have any idea on how to fix it?
    Did you make any change related to the code recently that may be causing this?

  9. reymon359 commented on Mar 27, 2023

    @reymon359

    Btw, I created an issue for the above #4207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions