Skip to content

Commit 84e2209

Browse files
committed
Focus first matrix input
1 parent 68d0e21 commit 84e2209

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/assets/css/common.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@ header.vff-header svg.f-logo {
823823
}
824824

825825
.vff .f-field-control:hover ~ .f-field-mask .f-field-svg,
826-
.vff .f-field-control:checked ~ .f-field-mask .f-field-svg {
826+
.vff .f-field-control:checked ~ .f-field-mask .f-field-svg,
827+
.vff .f-field-control:focus ~ .f-field-mask .f-field-svg {
827828
fill: currentColor;
828829
}
829830

src/components/QuestionTypes/MatrixType.vue

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@
3535
<label class="f-matrix-field f-matrix-radio">
3636
<input
3737
type="radio"
38-
v-bind:ref="el => inputList[row.id].push(el)"
38+
v-bind:ref="el => inputList.push(el)"
3939
v-bind:name="row.id"
4040
v-bind:id="'c' + index + '-' + row.id"
4141
v-bind:aria-label="row.label"
42+
v-bind:data-id="row.id"
4243
v-bind:value="column.value"
4344
v-model="selected[row.id]"
4445
class="f-field-control f-radio-control"
@@ -58,9 +59,10 @@
5859
<label class="f-matrix-field f-matrix-checkbox">
5960
<input
6061
type="checkbox"
61-
v-bind:ref="el => inputList[row.id].push(el)"
62+
v-bind:ref="el => inputList.push(el)"
6263
v-bind:id="'c' + index + '-' + row.id"
6364
v-bind:aria-label="row.label"
65+
v-bind:data-id="row.id"
6466
v-bind:value="column.value"
6567
class="f-field-control f-checkbox-control"
6668
v-model="selected[row.id]"
@@ -100,7 +102,7 @@ export default {
100102
data() {
101103
return {
102104
selected: {},
103-
inputList: {}
105+
inputList: []
104106
}
105107
},
106108
@@ -113,11 +115,6 @@ export default {
113115
} else if (this.question.answer) {
114116
this.selected = {...this.question.answer}
115117
}
116-
117-
// Setting input list for validation
118-
for (let row of this.question.rows) {
119-
this.inputList[row.id] = []
120-
}
121118
},
122119
123120
methods: {
@@ -135,11 +132,31 @@ export default {
135132
136133
const checked = inputs => inputs.some(input => input.checked)
137134
138-
if (!Object.values(this.inputList).every(value => checked(value))) {
135+
if (!Object.values(this.inputGroups).every(value => checked(value))) {
139136
return false
140137
}
141138
142139
return true
140+
},
141+
142+
getElement() {
143+
return this.inputList[0]
144+
},
145+
},
146+
147+
computed: {
148+
inputGroups() {
149+
let inputGroups = {}
150+
// Setting input list for validation
151+
for (let row of this.question.rows) {
152+
inputGroups[row.id] = []
153+
}
154+
155+
this.inputList.forEach(input => {
156+
inputGroups[input.dataset.id].push(input)
157+
})
158+
159+
return inputGroups
143160
}
144161
}
145162
}

0 commit comments

Comments
 (0)