Skip to content

fix(files): pin editor bubble menus to the cursor during scroll - #6434

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

fix(files): pin editor bubble menus to the cursor during scroll#6434
waleedlatif1 merged 1 commit into
stagingfrom
fix/bubble-menu-native-pin

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up to fix(files): anchor editor bubble menus to the selection on scroll #6419. That fix made the toolbars follow the selection, but because they were position: fixed and portaled to <body>, TipTap repositioned them on a debounced scroll listener — so they visibly lagged and "chased" the cursor during scroll.
  • Leave the menus at TipTap's default absolute strategy and append them into the editor's scroll container (now a positioning context via relative). They become absolutely-positioned children of the scrolled content and track the selection through native scrolling — no scroll listener, no lag.
  • TipTap's default flip/shift still park the toolbar above/below the selection at the pane edges, and the container's overflow clips it once the selection scrolls out of view.
  • Net simplification: drops the scrollTarget/hide/fixed options plumbing.

Type of Change

  • Bug fix

Testing

Empirically verified in a Playwright harness against the real menu components:

  • 0 px menu↔cell drift during scroll, measured same-frame (was 100s of px on fast scroll with the portal approach).
  • No clipping at the top edge (flips below), bottom edge (flips above), or table edges.
  • 521 rich-markdown-editor unit tests pass; type-check + biome clean.

Trade-off considered: native positioning can clip the wide text toolbar only if the file pane is narrower than the toolbar (~382 px); the table menu (~262 px) is unaffected. The body-portal bounce was confirmed unfixable via settings, so native pin was chosen for the smoothness.

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)

The text and table toolbars were positioned `fixed` and portaled to `<body>`, so TipTap
repositioned them on a debounced scroll listener — the toolbar visibly lagged and "chased"
the cursor as the pane scrolled.

Leave the menus at TipTap's default `absolute` strategy and append them into the editor's
scroll container (now a positioning context) so they become absolutely-positioned children
of the scrolled content and track the selection through native scrolling — no scroll
listener, so no lag. TipTap's default `flip`/`shift` keep the toolbar above/below the
selection at the pane edges, and the container's overflow clips it once the selection
scrolls out of view.

Verified in a harness: 0px menu-to-cell drift during scroll (was 100s of px on fast
scroll), and no clipping at the top, bottom, or table edges.
@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 8:12pm

Request Review

@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI-only editor toolbar positioning in the rich markdown file viewer; no auth, persistence, or API changes.

Overview
Fixes bubble menu lag when scrolling the file editor: text and table toolbars no longer chase the selection behind a debounced scroll listener.

Positioning change: Menus are appended into the editor scroll container (not document.body) and use TipTap’s default absolute floating strategy instead of fixed. The scroll wrapper gets relative so menus move with scrolled content natively. Custom Floating UI options (scrollTarget, hide, fixed) and related state in useBubbleMenuFloating are removed; both bubble menus stop passing options to BubbleMenu.

Trade-off: The wide formatting bar can clip if the pane is narrower than the toolbar; overflow on the container hides menus when the selection scrolls out of view.

Reviewed by Cursor Bugbot for commit a2acda1. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR changes the rich-markdown editor’s text and table bubble menus from fixed, body-portaled overlays to absolutely positioned children of the editor’s scroll container.

  • Appends both menus to the editor container and removes fixed positioning, explicit scroll-target tracking, and hide middleware.
  • Makes the scroll container a positioning context so native scrolling moves the menus with their selections.
  • Retains a shared virtual selection anchor for text and table menus.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified in the changed positioning flow.

The editor container is established as the menus’ positioning and clipping context, native scrolling moves the menus with their selections, and the portal callback resolves after the parent container ref is committed.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/bubble-menu.tsx Removes explicit Floating UI options while retaining the shared selection anchor and new container portal target.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/table-menu.tsx Applies the same native-scroll positioning behavior to the table editing toolbar.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/use-bubble-menu-floating.ts Simplifies the positioning hook to provide a live selection anchor and append menus to the editor scroll container.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/rich-markdown-editor.tsx Adds a relative positioning context to the existing overflow-scrolling editor container.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Selection[Editor selection] --> Anchor[Virtual DOM anchor]
  Anchor --> Menu[Absolute bubble menu]
  Container[Relative overflow container] --> Menu
  Scroll[Native container scroll] --> Container
  Container -->|moves and clips child| Menu
Loading

Reviews (1): Last reviewed commit: "fix(files): pin editor bubble menus to t..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit 9f50508 into staging Aug 8, 2026
24 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/bubble-menu-native-pin branch August 8, 2026 20:16

@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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a2acda1. 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