TypeScript
fix(web): fast typing no longer scrambles text when type-to-focus kicks in (#14595)
Otavio Salvador26285ab80513
diff --git a/apps/web/src/components/ComposerPromptEditorTiptap.tsx b/apps/web/src/components/ComposerPromptEditorTiptap.tsxindex 6b7eb7df706..bac965c0b97 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.