From e1f880a62ba95ee1dde02aacfe700fd835bbebcb Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Wed, 8 Jan 2025 09:16:34 +0000 Subject: [PATCH] Wrap dispatchSelectionAndScroll in setTimeout (#22596) GitOrigin-RevId: 8c2c27acdbbf0e8879978e307ccf952c1be5381e --- .../source-editor/extensions/cursor-position.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/services/web/frontend/js/features/source-editor/extensions/cursor-position.ts b/services/web/frontend/js/features/source-editor/extensions/cursor-position.ts index eafa407dce..52579b1940 100644 --- a/services/web/frontend/js/features/source-editor/extensions/cursor-position.ts +++ b/services/web/frontend/js/features/source-editor/extensions/cursor-position.ts @@ -122,12 +122,13 @@ const dispatchSelectionAndScroll = ( view: EditorView, selection: SelectionRange ) => { - view.dispatch({ - selection, - effects: EditorView.scrollIntoView(selection, { y: 'center' }), + window.setTimeout(() => { + view.dispatch({ + selection, + effects: EditorView.scrollIntoView(selection, { y: 'center' }), + }) + view.focus() }) - - view.focus() } export const setCursorLineAndScroll = (