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

Cursor gets stuck when typing at the end of a line on an Android device #1358

Closed
lovelle-cardoso opened this issue Mar 24, 2024 · 11 comments
Closed

Comments

@lovelle-cardoso
Copy link

Describe the issue

Reproduction Steps:

  1. On an android device, load any codemirror editor that uses a language package. (The example editors on https://codemirror.net/examples/lang-package and https://codemirror.net/examples/mixed-language both exhibit this bug on my Android phone.)

  2. Try typing test at the end of any line in the editor.

Expected Result:

The word test is typed at the end of the line.

Actual Result:

Because the cursor gets stuck for the first two characters, instead of typing test the editor types stet

Additional Notes:

We noticed this bug in our editor after updating our codemirror packages to the latest version. This bug seems to only appear on Android. It works fine on iOS and desktop. It also seems to only happen in the language package examples on the codemirror website. The other examples work fine.

AndroidKeyboardBug

Browser and platform

Android, Samsung Galaxy 10+, Samsung Mobile Browser & Chrome Mobile Browser, Default android keyboard

Reproduction link

https://codemirror.net/examples/mixed-language

@lishid
Copy link

lishid commented Mar 30, 2024

We have recently updated codemirror-view to 6.24.1 4e355ea (previously using 6.21.4 5dfda8e) and we are getting a lot of reports for this issue as well. Lots of details and videos (inconveniently in zip files) at https://forum.obsidian.md/t/cursor-ends-up-before-the-letter-on-android-samsung-keyboard/78185

In addition, we are also seeing a similar issue on desktop with IMEs with details here, which I am also able to reproduce in the mixed-language demo page: https://forum.obsidian.md/t/problem-with-cursor-positioning-after-some-formatting-symbols-when-using-input-method-ime-cjk/78455

@marijnh Has this been reproducible at all? We would be grateful if you can take a look at it as we are getting a significant amount of users running into this, and our app store reviews has seem better days as well 😂.

@lishid
Copy link

lishid commented Mar 30, 2024

I have bisected the problem to be from the commit codemirror/view@4e355ea

@lovelle-cardoso
Copy link
Author

@marijnh Any workaround for this? Or should we just roll back codemirror/view to 6.24.1 for now?

@marijnh
Copy link
Member

marijnh commented Apr 3, 2024

It looks like 6.26.1 already makes this less disruptive—the cursor still appears in the wrong place after starting a single letter, but continuing to type does the expected thing.

The underlying issue here seems to be a bug in that virtual keyboard, which mispositions the cursor when the DOM changes right at the start of the composition, putting it before instead of after the typed character. Other keyboards like GBoard don't have this problem.

@lovelle-cardoso
Copy link
Author

@marijnh Updating to 6.26.1 seems to fix things (on my Android phone at least) Thanks! I'm not sure if it fixes it in all the situations @lishid describes, but in my case, you're welcome to close this bug.

@lishid
Copy link

lishid commented Apr 4, 2024

I will update and test again in a few days, thanks!

@lovelle-cardoso
Copy link
Author

@marijnh Actually, spoke too soon! This is still broken for me.

@lovelle-cardoso
Copy link
Author

@lishid I see that Obsidian was able to workaround this bug for their latest 1.5.12 update. Was that accomplished by simply downgrading codemirror to a particular version?

@lishid
Copy link

lishid commented Apr 8, 2024

@lishid I see that Obsidian was able to workaround this bug for their latest 1.5.12 update. Was that accomplished by simply downgrading codemirror to a particular version?

We have a fork on which I've performed a revert on the specific commit.

@lovelle-cardoso
Copy link
Author

@lishid Thanks! Following suit, we have also forked @codemirror/view and reverted commit codemirror/view@4e355ea to get things working again on Android devices. It's a bit difficult to maintain, but it'll do as a temporary workaround!

@marijnh if there is some sort of configuration option we could utilize to skip this composition barrier logic, let us know! Otherwise, we'll just keep working off of a fork for now.

marijnh added a commit to codemirror/view that referenced this issue Apr 9, 2024
FIX: Remove the workaround that avoided inappropriate styling on composed text after
a decoration again, since it breaks the stock Android virtual keyboard.

Issue codemirror/dev#1358
Issue codemirror/dev#1324
@marijnh
Copy link
Member

marijnh commented Apr 9, 2024

I haven't been able to find a way to fix #1324 without triggering this misbehavior in the virtual keyboard, so I went ahead and reverted that fix in 6.26.2. Experimenting with using EditContext to sidestep this whole pile of hacks, but that's a major project, and might take a while.

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

No branches or pull requests

3 participants