fix(web): fast typing no longer scrambles text when type-to-focus kicks in (#14595)

This commit is contained in:
Otavio Salvador authored and GitHub committed 2026-10-07 14:03:31 -07:00
1 parent eba0521563
commit 26285ab805
1 file changed
+5 -1
@@ -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.