Skip to content

Commit 96877e6

Browse files
committed
feat(texteditor)[a11y]: make editor focusable with keyboard
1 parent 39e52da commit 96877e6

5 files changed

Lines changed: 43 additions & 11 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
:mode="isAnswerOpen(answerIdx) ? 'edit' : 'view'"
8181
@update="updateAnswerText($event, answerIdx)"
8282
@minimize="emitClose"
83+
@open-editor="emitOpen(answerIdx)"
8384
/>
8485
</div>
8586
</keep-alive>

contentcuration/contentcuration/frontend/channelEdit/components/AssessmentItemEditor/AssessmentItemEditor.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,22 @@
6363
<TipTapEditor
6464
v-model="question"
6565
mode="view"
66+
tabindex="-1"
6667
/>
6768
</VFlex>
6869

6970
<VFlex shrink>
70-
<Icon
71-
:color="$themePalette.grey.v_800"
72-
icon="edit"
73-
class="mr-2"
74-
/>
71+
<button
72+
class="v-btn v-btn--flat v-btn--icon v-size--default"
73+
data-test="editQuestionButton"
74+
@click.stop="openQuestion"
75+
>
76+
<Icon
77+
:color="$themePalette.grey.v_800"
78+
icon="edit"
79+
class="mr-2"
80+
/>
81+
</button>
7582
</VFlex>
7683
</VLayout>
7784
</div>

contentcuration/contentcuration/frontend/channelEdit/components/AssessmentItemPreview/AssessmentItemPreview.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<TipTapEditor
1313
v-model="question"
1414
mode="view"
15+
tabindex="-1"
1516
/>
1617
</VFlex>
1718
</VLayout>
@@ -45,6 +46,7 @@
4546
<TipTapEditor
4647
v-model="answer.answer"
4748
mode="view"
49+
tabindex="-1"
4850
/>
4951
</div>
5052
</template>
@@ -64,6 +66,7 @@
6466
<TipTapEditor
6567
v-model="answer.answer"
6668
mode="view"
69+
tabindex="-1"
6770
/>
6871
</div>
6972
</Checkbox>
@@ -115,6 +118,7 @@
115118
<TipTapEditor
116119
v-model="hint.hint"
117120
mode="view"
121+
tabindex="-1"
118122
/>
119123
</VFlex>
120124
</VLayout>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
:mode="isHintOpen(hintIdx) ? 'edit' : 'view'"
4141
@update="updateHintText($event, hintIdx)"
4242
@minimize="emitClose"
43+
@open-editor="emitOpen(answerIdx)"
4344
/>
4445
</keep-alive>
4546
</transition>

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
ref="editorContainer"
55
class="editor-container"
66
:class="{ 'view-mode': editorMode === 'view' }"
7+
:tabindex="tabindex"
8+
role="textbox"
9+
:aria-label="
10+
editorMode === 'edit' ? 'text editor - Press Enter to start editing' : 'text editor content'
11+
"
12+
aria-multiline="true"
13+
@keydown="handleContainerKeydown"
714
>
815
<div v-if="editorMode === 'edit'">
916
<EditorToolbar
@@ -84,6 +91,7 @@
8491
</div>
8592

8693
<EditorContentWrapper
94+
:inert="editorMode === 'view'"
8795
@drop.native.prevent="handleDrop"
8896
@dragover.native.prevent
8997
/>
@@ -246,6 +254,12 @@
246254
{ deep: true },
247255
);
248256
257+
const handleContainerKeydown = event => {
258+
if (event.key === 'Enter') {
259+
emit('open-editor');
260+
}
261+
};
262+
249263
return {
250264
editorContainer,
251265
isReady,
@@ -259,12 +273,9 @@
259273
sharedEventHandlers,
260274
editorMode: computed(() => props.mode),
261275
emitMinimize: () => {
262-
// force lose focus
263-
if (editor.value) {
264-
emit('minimize');
265-
editor.value.commands.blur();
266-
}
276+
emit('minimize');
267277
},
278+
handleContainerKeydown,
268279
};
269280
},
270281
props: {
@@ -276,8 +287,12 @@
276287
type: String,
277288
default: 'edit', // 'edit' or 'view'
278289
},
290+
tabindex: {
291+
type: [String, Number],
292+
default: 0,
293+
},
279294
},
280-
emits: ['update', 'minimize'],
295+
emits: ['update', 'minimize', 'open-editor'],
281296
});
282297
283298
</script>
@@ -306,6 +321,10 @@
306321
border: 0;
307322
}
308323
324+
.editor-container:focus-visible {
325+
outline-color: #007bff;
326+
}
327+
309328
.link-editor-popover-wrapper,
310329
.image-upload-popover-wrapper,
311330
.math-modal-popover-wrapper {

0 commit comments

Comments
 (0)