Skip to content

Commit 132dd6d

Browse files
committed
Fix validation for arrays
1 parent 325cea5 commit 132dd6d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/components/QuestionTypes/BaseType.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
allowedChars: null,
3232
alwaysAllowedKeys: ['ArrowLeft', 'ArrowRight', 'Delete', 'Backspace'],
3333
focused: false,
34-
canReceiveFocus: false,
34+
canReceiveFocus: false
3535
}
3636
},
3737
mounted() {
@@ -166,6 +166,11 @@
166166
return v.trim().length > 0
167167
}
168168
169+
if (Array.isArray(v)) {
170+
// Don't allow empty arrays
171+
return v.length > 0
172+
}
173+
169174
// All other non-null values are allowed to pass through
170175
return true
171176
}

src/components/QuestionTypes/MultipleChoiceType.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,36 +54,39 @@
5454
export default {
5555
extends: BaseType,
5656
name: QuestionType.MultipleChoice,
57+
5758
data() {
5859
return {
5960
editingOther: false
6061
}
6162
},
63+
6264
mounted() {
6365
if (this.question.multiple) {
6466
this.dataValue = []
6567
}
6668
6769
this.addKeyListener()
6870
},
71+
6972
beforeDestroy() {
7073
this.removeKeyListener()
7174
},
75+
7276
watch: {
7377
active(value) {
7478
if (value) {
7579
this.addKeyListener()
7680
77-
if (this.question.multiple) {
78-
if (this.question.answered) {
79-
this.enterPressed = false
80-
}
81+
if (this.question.multiple && this.question.answered) {
82+
this.enterPressed = false
8183
}
8284
} else {
8385
this.removeKeyListener()
8486
}
8587
}
8688
},
89+
8790
methods: {
8891
addKeyListener() {
8992
this.removeKeyListener()

0 commit comments

Comments
 (0)