Skip to content

Google Docs: do not show suggestions when a click only moves the caret - #479

Merged
bartekplus merged 1 commit into
masterfrom
fix/docs-caret-move-no-suggestions
Oct 6, 2026
Merged

bartekplus merged 1 commit into
masterfrom
fix/docs-caret-move-no-suggestions

Conversation

@bartekplus

Copy link
Copy Markdown
Owner

Problem

In Google Docs, a click into existing text opened the suggestion menu, and an arrow key did the same, without any typing.

Root cause

The Docs adapter reads the model every 200 ms. It asks for suggestions when the new snapshot differs from the last one. A click (pointerdown) and each key call dismiss(), and dismiss() sets the stored snapshot to null. The next poll then has no snapshot to compare against, so it reads the moved caret as a change and asks for suggestions.

Fix

GoogleDocsAdapter has a new edited flag:

  • These actions set it: a keystroke, an input or a paste (queueEdit), the end of an IME composition, and our own write. Thus the next-word menu still shows after an accepted word.
  • dismiss() clears it.
  • A read uses the flag one time. A read without an edit or an explicit request (force, for example Ctrl+Space) asks for no suggestions.

Other editors

I checked whether other editors have the same bug. A new e2e test runs the same steps in 24 editor setups, each in menu mode and inline mode:

  • textarea, input and contenteditable
  • React-controlled input and textarea
  • CKEditor 4 and 5, Quill (classic, bundled 1, bundled 2)
  • Lexical, ProseMirror, Slate, TinyMCE (inline, iframe)
  • Gutenberg (inline, iframe canvas), Draft.js, Trix, Froala, Summernote, Tiptap, RoosterJS
  • the Notion-like page

For each one, it types text, then clicks into the middle of a word, presses arrow keys, and clicks back into the field from outside. All 48 cases pass in Chrome, so the bug is only in Google Docs. To prove the test can catch the bug, I added a click-triggered prediction on purpose. Then the test failed for textarea, contenteditable, Lexical and Notion.

Tests

  • Unit: tests/GoogleDocsAdapter.test.ts fails without the fix.
  • Integration: tests/e2e/google-docs.e2e.test.ts has a new test for a click and an arrow key that only move the caret. Without the fix, the menu opens. With the fix, all 91 Docs e2e tests pass.
  • E2E full: the editor matrix above.
  • bun run check, bun run test (0 failures) and bun run check:e2e:coverage pass. The coverage matrix has a new behavior, caret_move_shows_no_suggestion.

Reviewer notes

  • Firefox: I could not run the new e2e test in Firefox. Firefox does not start on my machine ("Could not find profile folder"). Please rely on CI for Firefox.
  • Live Google Docs: I have not tested this in live Google Docs. The fixture is a copy of the Docs DOM and bridge, not the real product.

🤖 Generated with Claude Code

… caret

In Google Docs, a click into existing text opened the suggestion menu.
An arrow key did the same. The user did not type.

Root cause: the adapter reads the Docs model every 200 ms. It asks for
suggestions when the new snapshot is not the same as the last one. A
click (pointerdown) and each key call dismiss(), and dismiss() sets the
stored snapshot to null. The next poll then had no snapshot to compare,
so it read the moved caret as a change and asked for suggestions.

Fix: a new "edited" flag. An edit sets it: a keystroke, an input, a
paste (queueEdit), the end of an IME composition, and our own write (so
the next-word menu still shows after an accepted word). dismiss()
clears it. A read uses it one time. A read without an edit or an
explicit request (force) asks for no suggestions.

Tests:
- unit (GoogleDocsAdapter.test.ts): a click and a poll ask for no
  suggestions; an edit does. It fails without the fix.
- integration (google-docs.e2e.test.ts): pointerdown plus a caret move,
  and an arrow key plus a caret move, request no suggestions, and the
  menu stays closed. Without the fix, the menu opens.
- e2e (full.e2e.test.ts): for 24 editor setups (textarea, input,
  contenteditable, React-controlled fields, CKEditor 4/5, Quill,
  Lexical, ProseMirror, Slate, TinyMCE, Gutenberg, Draft.js, Trix,
  Froala, Summernote, Tiptap, RoosterJS and the Notion-like page), in
  menu and inline mode: a click into the text, arrow keys, and a click
  back into the field show no suggestion. All 48 cases pass in Chrome.
  These editors did not have the bug. When a click asks for
  suggestions on purpose, the test fails.
- The coverage matrix has a new behavior, caret_move_shows_no_suggestion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@bartekplus
bartekplus merged commit 92100d2 into master Oct 6, 2026
13 checks passed
@bartekplus
bartekplus deleted the fix/docs-caret-move-no-suggestions branch October 6, 2026 20:44
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.

1 participant