Skip to content

Type Ahead: Fix ghost text placement and empty-block placeholder overlap#847

Merged
dkotter merged 2 commits into
WordPress:developfrom
yogeshbhutkar:fix/type-ahead-bugs
Jul 9, 2026
Merged

Type Ahead: Fix ghost text placement and empty-block placeholder overlap#847
dkotter merged 2 commits into
WordPress:developfrom
yogeshbhutkar:fix/type-ahead-bugs

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What, Why, and How?

Closes #846

  • Prevents ghost text from anchoring above the title or outside the active editable block.
  • Prevents Gutenberg’s empty-block placeholder from overlapping with type-ahead ghost text.
  • Invalidates stale in-flight suggestions when a pending request is cancelled.

Type Ahead depends on the current caret position and block focus to decide where a suggestion should appear. When the first empty paragraph is focused while a request is still resolving, Gutenberg can briefly report a caret rectangle outside the editable block. The overlay then trusts that stale or invalid geometry, causing ghost text to render above the title instead of inside the paragraph.

cancelPendingRequest() aborts the active request, but the abilitiesModule.executeAbility() path does not currently honor the AbortController signal. That means a cancelled request can still resolve later and apply a stale suggestion after focus has moved, causing ghost text to appear alongside Gutenberg’s placeholder. cancelPendingRequest() needs to also invalidate stale in-flight responses.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5.5
Used for: Code review and PR metadata. The changes are tested and reviewed by me.

Testing Instructions

  1. Enable the Type Ahead experiment.
  2. Open the block editor and create a post with an empty first paragraph below the title.
  3. Click into the first empty paragraph and wait for a type-ahead suggestion to resolve.
  4. Confirm the ghost text appears inside the paragraph, not above the title.
  5. Click into an empty paragraph so a type-ahead request starts.
  6. Before the request finishes, click outside the paragraph.
  7. Wait for the request to finish, then click back into the same empty paragraph.
  8. Confirm the ghost text does not overlap Gutenberg’s placeholder.
  9. Confirm accepting the suggestion with Tab still inserts the full suggestion.
  10. Confirm dismissing the suggestion with Escape still removes the ghost text.

Screencast

screencast.mov

Changelog Entry

Fixed - Type-ahead ghost text placement and stale suggestions overlapping empty-block placeholders.

Open WordPress Playground Preview

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.74%. Comparing base (cf0cb09) to head (214c486).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #847   +/-   ##
==========================================
  Coverage      75.74%   75.74%           
  Complexity      2088     2088           
==========================================
  Files             99       99           
  Lines           8630     8630           
==========================================
  Hits            6537     6537           
  Misses          2093     2093           
Flag Coverage Δ
unit 75.74% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yogeshbhutkar yogeshbhutkar changed the title Type Ahead: Fix type-ahead ghost text placement and empty-block placeholder overlap Type Ahead: Fix ghost text placement and empty-block placeholder overlap Jul 9, 2026
@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review July 9, 2026 11:05
@yogeshbhutkar yogeshbhutkar requested a review from a team July 9, 2026 11:05
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@dkotter dkotter added this to the 1.2.0 milestone Jul 9, 2026
@dkotter dkotter merged commit 9aa82ab into WordPress:develop Jul 9, 2026
27 of 28 checks passed
@yogeshbhutkar yogeshbhutkar deleted the fix/type-ahead-bugs branch July 9, 2026 18:07
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.

Type Ahead: Ghost text placement and empty-block placeholder overlap

2 participants