Skip to content

Commit dffce52

Browse files
committed
improvement(rich-md-editor): pin the formatting toolbar so it stays put while scrolling
1 parent 56f319f commit dffce52

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/bubble-menu.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ function hasFormattableSelection(editor: Editor, from: number, to: number): bool
7373
return editor.state.doc.textBetween(from, to, ' ').trim().length > 0
7474
}
7575

76+
// Pin the toolbar to the viewport (fixed) and never attach a scroll listener, so once it's placed for
77+
// a selection it stays put while the document scrolls instead of tracking the text — matching Linear.
78+
const FLOATING_OPTIONS = { strategy: 'fixed' } as const
79+
7680
interface EditorBubbleMenuProps {
7781
editor: Editor
7882
/** The editor's scrollable viewport, used to keep the toolbar on-screen for selections taller than it. */
@@ -228,6 +232,7 @@ export function EditorBubbleMenu({ editor, scrollContainerRef }: EditorBubbleMen
228232
editor={editor}
229233
pluginKey={bubbleMenuKey}
230234
getReferencedVirtualElement={resolveAnchor}
235+
options={FLOATING_OPTIONS}
231236
role='toolbar'
232237
aria-label='Text formatting'
233238
updateDelay={0}

0 commit comments

Comments
 (0)