Skip to content

Commit

Permalink
fix(core): fix focus command passing through editor state instead of …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
bdbch committed Jun 26, 2022
1 parent 15123ee commit 5b0b7d9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/commands/focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5b0b7d9

Please sign in to comment.