Skip to content

Commit 3a024b0

Browse files
rtibblesbotclaude
andcommitted
Fix interactive element accessibility: use native button elements
Replace div[role=button] with native <button> elements in QTISandboxPage and simplify scrollToSelectedLearner to always derive the element from the DOM ref rather than accepting it as a parameter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f045b07 commit 3a024b0

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

kolibri/plugins/coach/frontend/views/common/QuestionDetailLearnerList.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
item.focus();
9292
}
9393
this.$emit('select', learnerNumber);
94-
this.scrollToSelectedLearner(learnerNumber, item);
94+
this.scrollToSelectedLearner(learnerNumber);
9595
},
9696
isSelected(learnerNumber) {
9797
return Number(this.selectedLearnerNumber) === learnerNumber;
@@ -102,8 +102,8 @@
102102
nextLearner(learnerNumber) {
103103
return learnerNumber + 1 < this.learners.length ? learnerNumber + 1 : 0;
104104
},
105-
scrollToSelectedLearner(learnerNumber, selectedElement) {
106-
const el = selectedElement || this.$refs.learnerList.children[learnerNumber];
105+
scrollToSelectedLearner(learnerNumber) {
106+
const el = this.$refs.learnerList.children[learnerNumber];
107107
if (el) {
108108
const parent = this.$el.parentElement;
109109
parent.scrollTop = el.offsetHeight * (learnerNumber + 1) - parent.offsetHeight / 2;

kolibri/plugins/qti_viewer/frontend/components/QTISandboxPage.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,35 +109,29 @@
109109
<div v-if="category.items">
110110
<template v-for="item in category.items">
111111
<div :key="item.identifier || item.title">
112-
<div
112+
<button
113113
v-if="item.identifier"
114+
type="button"
114115
class="qti-item"
115-
role="button"
116-
tabindex="0"
117116
@click="selectItem(item)"
118-
@keydown.enter="selectItem(item)"
119-
@keydown.space.prevent="selectItem(item)"
120117
>
121118
<h4>{{ item.title }}</h4>
122-
</div>
119+
</button>
123120
<AccordionItem
124121
v-else-if="item.items"
125122
:title="item.title"
126123
class="nested-accordion"
127124
>
128125
<template #content>
129-
<div
126+
<button
130127
v-for="nestedItem in item.items"
131128
:key="nestedItem.identifier"
129+
type="button"
132130
class="nested-item qti-item"
133-
role="button"
134-
tabindex="0"
135131
@click="selectItem(nestedItem)"
136-
@keydown.enter="selectItem(nestedItem)"
137-
@keydown.space.prevent="selectItem(nestedItem)"
138132
>
139133
<h5>{{ nestedItem.title }}</h5>
140-
</div>
134+
</button>
141135
</template>
142136
</AccordionItem>
143137
</div>
@@ -382,9 +376,15 @@
382376
}
383377
384378
.qti-item {
379+
display: block;
380+
width: 100%;
385381
padding: 0.75rem;
386382
margin-bottom: 0.5rem;
383+
font: inherit;
384+
color: inherit;
385+
text-align: start;
387386
cursor: pointer;
387+
background: transparent;
388388
border: 1px solid #dddddd;
389389
border-radius: 4px;
390390
transition: background-color 0.2s;

0 commit comments

Comments
 (0)