From 26285ab80513260d1ff29d2c3fbe18f21990cb62 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Wed, 7 Oct 2026 18:03:31 -0300 Subject: [PATCH] fix(web): fast typing no longer scrambles text when type-to-focus kicks in (#14595) --- apps/web/src/components/ComposerPromptEditorTiptap.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/ComposerPromptEditorTiptap.tsx b/apps/web/src/components/ComposerPromptEditorTiptap.tsx index 6b7eb7df7066e0445229f2ec3ca8ab87bcf3a1ad..bac965c0b97db0587d8316393d38c7aab340777c 100644 --- a/apps/web/src/components/ComposerPromptEditorTiptap.tsx +++ b/apps/web/src/components/ComposerPromptEditorTiptap.tsx @@ -1210,7 +1210,11 @@ function ComposerPromptEditorTiptapInner(props: ComposerPromptEditorProps) { const focusAt = useCallback( (nextCursor: number) => { if (!editor) return; - editor.view.dom.focus({ preventScroll: true }); + // view.focus() writes the state selection to the DOM as it focuses. A + // bare DOM focus leaves the native caret at the start until + // ProseMirror resyncs it 20ms later, and dictation tools type fast + // enough to land keys there, ahead of the text already inserted. + editor.view.focus(); // A newer prompt is waiting to be applied (a chip was just inserted // through the store). Reporting the editor's stale text now would // overwrite that prompt; the pending rewrite places the caret instead. -- 2.54.0