Skip to content

fix(files): anchor editor bubble menus to the selection on scroll - #6419

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/bubble-menu-scroll-anchor
Aug 8, 2026
Merged

fix(files): anchor editor bubble menus to the selection on scroll#6419
waleedlatif1 merged 1 commit into
stagingfrom
fix/bubble-menu-scroll-anchor

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The text and table bubble menus stayed pinned to a viewport position when the file scrolled — click a table cell, scroll, and the toolbar floats over unrelated content instead of following the cell.
  • Root cause (from TipTap source): @tiptap/extension-bubble-menu doesn't use Floating UI autoUpdate; it repositions via a manual scroll listener whose target defaults to window. The editor scrolls inside an inner overflow-y:auto container, so that listener never fires — the menu only moved when the selection changed.
  • Fix: pass the editor's scroll container as the BubbleMenu scrollTarget (a first-class TipTap option) so it repositions with the selection, and enable Floating UI's hide middleware so the menu hides once its anchored cell scrolls out of view. Both menus now share one floating-anchor helper (anchor + options) so they can't drift.
  • Removes the prior workarounds that fought this: the strategy: 'fixed' viewport-pin, the resolveAnchor viewport-clamp branches, and the bubble menu's selection-keyed rect cache (which froze the menu in place on scroll). Net −60 lines.

Type of Change

  • Bug fix

Testing

  • Empirically verified in a Playwright harness (real editor + both menus in an inner scroll container): on scroll the menu's top delta matches the cell's delta (follows), and the menu goes visibility: hidden once the cell scrolls out of view.
  • 521 rich-markdown-editor unit tests pass; type-check clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 8, 2026 7:03pm

Request Review

@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI-only positioning refactor in the rich markdown editor bubble menus; no auth, data, or schema changes.

Overview
Fixes text and table bubble toolbars floating at a fixed viewport position when the file viewer scrolls inside its inner overflow container instead of following the selection.

Introduces shared useBubbleMenuFloating, which wires TipTap BubbleMenu to the editor scroll pane via scrollTarget, enables Floating UI hide when the anchor leaves the pane, and recomputes selection rects on every reposition (no selection-key cache). Both menus portal to document.body with strategy: 'fixed.

Removes duplicated anchor logic and prior viewport-clamp workarounds from bubble-menu.tsx and table-menu.tsx.

Reviewed by Cursor Bugbot for commit eb50d71. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR centralizes text and table bubble-menu anchoring in a shared hook, binds TipTap repositioning to the editor’s inner scroll container, and enables hiding when the selection leaves the clipping area.

  • Replaces selection-rect caching and viewport clamping with a live virtual selection anchor.
  • Shares Floating UI options and body portal behavior across both menus.
  • Supplies the editor scroll container as TipTap’s scroll target.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/bubble-menu.tsx Replaces inline text-menu anchoring and Floating UI configuration with the shared positioning hook.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/table-menu.tsx Replaces table-specific anchor clamping with the shared scroll-aware positioning hook.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/use-bubble-menu-floating.ts Adds the shared live selection anchor, scroll-target options, hide middleware, and body portal configuration.

Reviews (2): Last reviewed commit: "fix(files): anchor the editor bubble men..." | Re-trigger Greptile

The text and table bubble menus stayed pinned to a viewport position when the file
scrolled — clicking a table cell then scrolling left the toolbar floating over unrelated
content. TipTap v3's BubbleMenu reposition listener defaults to `window`, but the editor
scrolls inside an inner overflow container, so it never fired; the menu only moved when
the selection itself changed.

Pass the editor's scroll container as the BubbleMenu `scrollTarget` (a first-class TipTap
option) so it repositions with the selection, and enable Floating UI's `hide` middleware
so the menu hides once its anchored cell scrolls out of view. Share the anchor + options
through one `floating-anchor` helper so the two menus can't drift.

Removes the prior workarounds that fought this: the `strategy: 'fixed'` viewport-pin, the
resolveAnchor viewport-clamp branches, and the bubble menu's selection-keyed rect cache
(which froze the menu in place on scroll).

Verified in a harness: on scroll the menu delta matches the cell delta (follows), and it
hides once the cell leaves view.
@waleedlatif1
waleedlatif1 force-pushed the fix/bubble-menu-scroll-anchor branch from 241933e to eb50d71 Compare August 8, 2026 19:03
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit eb50d71. Configure here.

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