From 62f7898323140fda199ada9657a810f72da2513a Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Mon, 18 Sep 2023 16:04:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=A7=20Fix=20#2548?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Paul Berg <9824244+Pangoraw@users.noreply.github.com> --- frontend/components/CellInput.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/components/CellInput.js b/frontend/components/CellInput.js index 33cdb5e2e8..247775d413 100644 --- a/frontend/components/CellInput.js +++ b/frontend/components/CellInput.js @@ -644,14 +644,16 @@ export const CellInput = ({ if (!caused_by_window_blur) { // then it's caused by focusing something other than this cell in the editor. // in this case, we want to collapse the selection into a single point, for aesthetic reasons. - view.dispatch({ - selection: { - anchor: view.state.selection.main.head, - }, - scrollIntoView: false, - }) - // and blur the DOM again (because the previous transaction might have re-focused it) - view.contentDOM.blur() + setTimeout(() => { + view.dispatch({ + selection: { + anchor: view.state.selection.main.head, + }, + scrollIntoView: false, + }) + // and blur the DOM again (because the previous transaction might have re-focused it) + view.contentDOM.blur() + }, 0) set_cm_forced_focus(null) }