Skip to content

Commit 6b4c0fc

Browse files
committed
Make sure to not add already added options
1 parent 1ca0481 commit 6b4c0fc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/QuestionTypes/MultipleChoiceType.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,20 @@
169169
},
170170
171171
_toggleAnswer(option) {
172+
const optionValue = option.choiceValue()
173+
172174
option.toggle()
173175
174176
if (this.question.multiple) {
175177
this.enterPressed = false
176178
177179
if (!option.selected) {
178-
this._removeAnswer(option.choiceValue())
179-
} else {
180-
this.dataValue.push(option.choiceValue())
180+
this._removeAnswer(optionValue)
181+
} else if (this.dataValue.indexOf(optionValue) === -1) {
182+
this.dataValue.push(optionValue)
181183
}
182184
} else {
183-
this.dataValue = option.selected ? option.choiceValue() : null
185+
this.dataValue = option.selected ? optionValue : null
184186
}
185187
186188
if (this.isValid() && this.question.nextStepOnAnswer && !this.question.multiple) {

0 commit comments

Comments
 (0)