From 5b0b7d91023c87e9ddb85ff3a776273d12a22d16 Mon Sep 17 00:00:00 2001 From: Dominik Biedebach Date: Sun, 26 Jun 2022 09:53:45 +0200 Subject: [PATCH] fix(core): fix focus command passing through editor state instead of existing transaction this fixes a bug introduced a few months ago that caused positions not resolving on the most recent transaction but the editor state that was existing before the last transactions beforehand existed causing the editor to crash --- packages/core/src/commands/focus.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/commands/focus.ts b/packages/core/src/commands/focus.ts index dbb2faeb7..cebd877c0 100644 --- a/packages/core/src/commands/focus.ts +++ b/packages/core/src/commands/focus.ts @@ -60,7 +60,9 @@ export const focus: RawCommands['focus'] = (position = null, options = {}) => ({ return true } - const selection = resolveFocusPosition(editor.state.doc, position) || editor.state.selection + // pass through tr.doc instead of editor.state.doc + // since transactions could change the editors state before this command has been run + const selection = resolveFocusPosition(tr.doc, position) || editor.state.selection const isSameSelection = editor.state.selection.eq(selection) if (dispatch) {