Skip to content

Fix autocomplete not triggering on mobile (CM5 input handling)#4017

Merged
raclim merged 2 commits intoprocessing:developfrom
aashu2006:fix/mobile-autocomplete
Apr 3, 2026
Merged

Fix autocomplete not triggering on mobile (CM5 input handling)#4017
raclim merged 2 commits intoprocessing:developfrom
aashu2006:fix/mobile-autocomplete

Conversation

@aashu2006
Copy link
Copy Markdown
Contributor

Issue:

Fixes #4007

This PR builds on the issue identified and discussed by @skyash-dev and me at Discord. We focused on investigating the mobile input behavior in CodeMirror and then I implementing a fix for the autocomplete trigger.

Autocomplete suggestions were not triggering reliably on mobile devices due to differences in CodeMirror’s input handling (IME + contenteditable path in CM5)

Demo:

Tested on a real Android device (Chrome). Autocomplete now appears while typing with the virtual keyboard.

Changes:

  • Added mobile compatible autocomplete triggering using:
    • change (desktop input)
    • compositionend (word commit on mobile)
    • compositionupdate (IME typing support)
  • Introduced triggerHint helper to unify logic
  • Handled trailing spaces e.g. "bac " to ensure correct token detection
  • Cleaned up debug code and simplified the logic

Notes:

  • This PR focuses on fixing the autocomplete trigger issue on mobile (CM5).
  • Keyboard focus behavior (virtual keyboard closing on suggestions) is not addressed here and I am thinking of handling it separately from this.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • has no typecheck errors (npm run typecheck)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123
  • meets the standards outlined in the accessibility guidelines

@aashu2006
Copy link
Copy Markdown
Contributor Author

@raclim would appreciate your thoughts here as well, especially since this relates to the earlier discussion around mobile autocomplete behavior, thanks!

Copy link
Copy Markdown
Collaborator

@raclim raclim left a comment

Choose a reason for hiding this comment

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

Thanks so much for your collaboration on this @aashu2006 and @skyash-dev, it's really awesome to see how the both of you pulled this together! I think this looks great, and will hold the fort until CM6 comes out!

@raclim raclim merged commit e0deabe into processing:develop Apr 3, 2026
1 check passed
@skyash-dev
Copy link
Copy Markdown

@aashu2006 last time when i tested this mobile keyboard issue was not solved...

is this solved?

ref: "the keyboard closes when the hint menu appears because focus seems to shift away from the editor. i tried removing .click() usage, preventing default on hint interactions, and simplifying to e.pick()-based selection, but it still closes the keyboard."

@aashu2006
Copy link
Copy Markdown
Contributor Author

@skyash-dev Yes, the autocomplete trigger part is fixed now, but the keyboard still closes on mobile when the hint menu appears.

I did try few approaches like refocusing after showHint, preventing default on hint interactions, tweaking some CM5 internals, but couldn’t resolve it. mentioned this on Discord as well.. seems like it’s tied more to how the browser/CM5 handles the hint UI.

we handle this as a follow up PR since it’s a separate issue from the trigger 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

Development

Successfully merging this pull request may close these issues.

Autocomplete suggestions not working consistently on mobile devices

3 participants