Skip to content

feat(suggestion-menu): anchor to the host's text - #534

Merged
kianbazza merged 1 commit into
ui-562-announce-suggestion-results-to-screen-readersfrom
ui-563-anchor-the-suggestion-menu-to-the-hosts-text
Sep 29, 2026
Merged

kianbazza merged 1 commit into
ui-562-announce-suggestion-results-to-screen-readersfrom
ui-563-anchor-the-suggestion-menu-to-the-hosts-text

Conversation

@kianbazza

@kianbazza kianbazza commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

SuggestionMenu anchors the popup to the host's text.

  • anchor: () => DOMRect | null. The popup follows the text when the page or field scrolls. A new position is computed only when the measured rect changes. null keeps the last position, and nothing is measured on close, when the text may already be gone.
  • SuggestionMenu.Positioner places the popup below, aligned to the start. If there's no room below it opens above, and it keeps that side until it closes, so it never flips while the user types or results stream in. It never goes beside the anchor, where it would cover the text.
open near the bottom -> Base UI flips it above -> held above
type "q" (1 row, would fit below) -> stays above

The side is read once Base UI has positioned against an anchor measured during this opening. In a background tab, where frames don't run, it's read on the first keystroke instead.

Evidence

suggestion-menu.anchor.test.tsx (24 tests) gives the viewport a real size in jsdom:

  • Flips at open, including under StrictMode.
  • The side is held through typing and through an anchor move that would fit below.
  • The popup never goes beside the anchor.
  • Holding waits for a real anchor, including one that arrives with a keystroke or measures late on a reopen.
  • The anchor is measured again on each update, not on unrelated renders or on close.

Checked in Chromium with ProseMirror at 900×290: the popup opened above, stayed above after the list shrank to one row, and moved with the text when the page scrolled.

Merge Danger

Door: two-way

Blast Radius: SuggestionMenu only

Closes UI-563

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ui-canary Ready Ready Preview Sep 29, 2026 2:31pm UTC

Request Review

@kianbazza
kianbazza added this pull request to stack #526 September 29, 2026 01:44
@linear-code

linear-code Bot commented Sep 29, 2026

Copy link
Copy Markdown

UI-563

@kianbazza
kianbazza force-pushed the ui-563-anchor-the-suggestion-menu-to-the-hosts-text branch from be5c824 to 3c83451 Compare September 29, 2026 14:29
@kianbazza
kianbazza marked this pull request as ready for review September 29, 2026 14:45
@kianbazza
kianbazza merged commit a2035b5 into canary Sep 29, 2026
6 of 8 checks passed

This branch was successfully deployed

1 active deployment
Preview – ui-canary — 3c834516 Deployed Sep 29, 2026 by vercel[bot]
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