Skip to content

Commit 66938dd

Browse files
authored
Revert "fix(files): keep the reader's caret when the markdown editor settles (#10263)" (#10283)
This reverts commit 1734687.
1 parent 754a28e commit 66938dd

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,15 +1350,11 @@ export function LoadedRichMarkdownEditor({
13501350
// load-bearing and runs on every settle even when the body is unchanged — setContent maps a
13511351
// pre-existing selection onto the new doc, so a prior select-all survives as "select everything",
13521352
// permanently painting every divider/image with the rich-leaf-in-selection decoration (keymap.ts)
1353-
// until the user clicks away. setTextSelection (not .focus()) never steals DOM focus. A caret is
1354-
// already collapsed: moving it to the end would only take away where the reader just clicked,
1355-
// since an editable editor can take a click before its first settle lands.
1353+
// until the user clicks away. setTextSelection (not .focus()) never steals DOM focus.
13561354
runOffRender(() => {
13571355
syncEditorContent(content)
13581356
pendingCollapseRef.current = false
1359-
if (!editor.state.selection.empty) {
1360-
editor.commands.setTextSelection(editor.state.doc.content.size)
1361-
}
1357+
editor.commands.setTextSelection(editor.state.doc.content.size)
13621358
editor.setEditable(effectiveCanEdit && settledVerdict && collabReady)
13631359
if (shouldFocus) editor.commands.focus('end')
13641360
})
@@ -1370,9 +1366,7 @@ export function LoadedRichMarkdownEditor({
13701366
// run bumped the token), so a post-stream select-all can't keep the leaf-in-selection decoration.
13711367
if (pendingCollapseRef.current) {
13721368
pendingCollapseRef.current = false
1373-
if (!editor.state.selection.empty) {
1374-
editor.commands.setTextSelection(editor.state.doc.content.size)
1375-
}
1369+
editor.commands.setTextSelection(editor.state.doc.content.size)
13761370
}
13771371
if (settled) editor.setEditable(effectiveCanEdit && settled.verdict && collabReady)
13781372
})

0 commit comments

Comments
 (0)