Skip to content

Commit 213fc3b

Browse files
committed
Fix DropdownType
1 parent 5652b45 commit 213fc3b

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/components/QuestionTypes/DropdownType.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class
66
v-bind:value="dataValue"
77
v-on:change="onChange"
8-
v-on:keydown="onKeyDown"
8+
v-on:keydown="onKeyDownListener"
99
v-bind:required="question.required"
1010
>
1111
<option v-if="question.required" label=" " value="" disabled selected hidden>&nbsp;</option>
@@ -47,6 +47,12 @@
4747
export default {
4848
extends: BaseType,
4949
name: QuestionType.Dropdown,
50+
mounted() {
51+
document.addEventListener('select', this.onKeyDownListener)
52+
},
53+
beforeDestroy() {
54+
document.removeEventListener('select', this.onKeyDownListener)
55+
},
5056
computed: {
5157
answerLabel() {
5258
for (let i = 0; i < this.question.options.length; i++) {
@@ -60,12 +66,17 @@
6066
return this.question.placeholder
6167
}
6268
},
63-
watch: {
64-
dataValue(value) {
65-
if (this.isValid()) {
66-
this.onEnter()
67-
69+
methods: {
70+
onKeyDownListener($event) {
71+
72+
if ($event.key === 'ArrowDown' || $event.key === 'ArrowUp') {
73+
this.setAnswer(this.dataValue)
74+
}
75+
if ($event.key === 'Enter' && this.isValid()) {
76+
$event.stopPropagation()
77+
this._onEnter()
6878
this.$emit('next')
79+
return
6980
}
7081
}
7182
}

0 commit comments

Comments
 (0)