Skip to content

Commit 7c45abf

Browse files
akolsonclaude
andcommitted
fix(exercises): autofocus RTE when answer/hint editor opens
Answer and hint fields now receive focus when their RTE opens (on click or when a new answer/hint is added), matching the existing behaviour of the question editor. Cursor is placed at the end of any existing text so the user can type immediately. Also fixes a pre-existing bug in HintsEditor desktop layout where @open-editor was passing the undefined variable `answerIdx` instead of `hintIdx`. Fixes #5885 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e3bbe30 commit 7c45abf

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

contentcuration/contentcuration/frontend/channelEdit/components/AnswersEditor/AnswersEditor.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
v-model="answer.answer"
9595
class="editor"
9696
:mode="isAnswerOpen(answerIdx) ? 'edit' : 'view'"
97+
:autofocus="isAnswerOpen(answerIdx)"
9798
:imageProcessor="EditorImageProcessor"
9899
@update="updateAnswerText($event, answerIdx)"
99100
@minimize="emitClose"
@@ -164,6 +165,7 @@
164165
v-model="answer.answer"
165166
class="editor"
166167
:mode="isAnswerOpen(answerIdx) ? 'edit' : 'view'"
168+
:autofocus="isAnswerOpen(answerIdx)"
167169
:imageProcessor="EditorImageProcessor"
168170
@update="updateAnswerText($event, answerIdx)"
169171
@minimize="emitClose"

contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<TipTapEditor
5252
v-model="hint.hint"
5353
:mode="isHintOpen(hintIdx) ? 'edit' : 'view'"
54+
:autofocus="isHintOpen(hintIdx)"
5455
:image-processor="EditorImageProcessor"
5556
@update="updateHintText($event, hintIdx)"
5657
@minimize="emitClose"
@@ -79,10 +80,11 @@
7980
<TipTapEditor
8081
v-model="hint.hint"
8182
:mode="isHintOpen(hintIdx) ? 'edit' : 'view'"
83+
:autofocus="isHintOpen(hintIdx)"
8284
:image-processor="EditorImageProcessor"
8385
@update="updateHintText($event, hintIdx)"
8486
@minimize="emitClose"
85-
@open-editor="emitOpen(answerIdx)"
87+
@open-editor="emitOpen(hintIdx)"
8688
/>
8789
</keep-alive>
8890
</transition>

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/TipTapEditor.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@
205205
if (editor.value && editor.value.isEditable !== (newMode === 'edit')) {
206206
editor.value.setEditable(newMode === 'edit');
207207
}
208+
if (newMode === 'edit' && editor.value && props.autofocus) {
209+
nextTick(() => {
210+
editor.value.commands.focus('end');
211+
});
212+
}
208213
},
209214
);
210215

0 commit comments

Comments
 (0)