From 763f61057b739983a15130e221b3f6590108fe7c Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Mon, 25 Mar 2024 20:24:37 +0100 Subject: [PATCH] fix(plugin-blanks): alternative answers safari focus bug --- .../editor/src/plugins/blanks-exercise/blank-renderer.tsx | 1 + packages/editor/src/store/focus/slice.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/plugins/blanks-exercise/blank-renderer.tsx b/packages/editor/src/plugins/blanks-exercise/blank-renderer.tsx index a2839ba7f2..6a0afda4a4 100644 --- a/packages/editor/src/plugins/blanks-exercise/blank-renderer.tsx +++ b/packages/editor/src/plugins/blanks-exercise/blank-renderer.tsx @@ -154,6 +154,7 @@ export function BlankRenderer(props: BlankRendererProps) { } function handleAlternativeAnswerAdd() { + ReactEditor.blur(editor) setCorrectAnswers([...correctAnswers, { answer: '' }]) } diff --git a/packages/editor/src/store/focus/slice.ts b/packages/editor/src/store/focus/slice.ts index 8be41d292d..8530afbd05 100644 --- a/packages/editor/src/store/focus/slice.ts +++ b/packages/editor/src/store/focus/slice.ts @@ -24,9 +24,9 @@ export const focusSlice = createSlice({ }, focusPrevious(state, action: PayloadAction) { if (!state || !action.payload) return state - const next = findPreviousChildTreeNode(action.payload, state) - if (!next) return state - return next + const previous = findPreviousChildTreeNode(action.payload, state) + if (!previous) return state + return previous }, }, extraReducers: (builder) => {