Skip to content

Commit 26285ab

Browse files
authored
fix(web): fast typing no longer scrambles text when type-to-focus kicks in (#14595)
1 parent eba0521 commit 26285ab

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎apps/web/src/components/ComposerPromptEditorTiptap.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,11 @@ function ComposerPromptEditorTiptapInner(props: ComposerPromptEditorProps) {
12101210
const focusAt = useCallback(
12111211
(nextCursor: number) => {
12121212
if (!editor) return;
1213-
editor.view.dom.focus({ preventScroll: true });
1213+
// view.focus() writes the state selection to the DOM as it focuses. A
1214+
// bare DOM focus leaves the native caret at the start until
1215+
// ProseMirror resyncs it 20ms later, and dictation tools type fast
1216+
// enough to land keys there, ahead of the text already inserted.
1217+
editor.view.focus();
12141218
// A newer prompt is waiting to be applied (a chip was just inserted
12151219
// through the store). Reporting the editor's stale text now would
12161220
// overwrite that prompt; the pending rewrite places the caret instead.

0 commit comments

Comments
 (0)