File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 3636 },
3737 mounted () {
3838 if (this .question .answer ) {
39- this .dataValue = this .question .answer
39+ this .dataValue = this .answer = this . question .answer
4040 } else if (this .question .multiple ) {
4141 this .dataValue = []
4242 }
Original file line number Diff line number Diff line change 7070 },
7171
7272 mounted () {
73- if (this .question .multiple ) {
74- this .dataValue = []
73+ if (this .question .answer ) {
74+ // Set initial answer when we have one
75+ this .question .options .forEach (o => {
76+ const optionValue = o .choiceValue ()
77+
78+ if (this .question .answer === optionValue || (Array .isArray (this .question .answer ) && this .question .answer .indexOf (optionValue) !== - 1 )) {
79+ this .toggleAnswer (o)
80+ }
81+ })
7582 }
7683
7784 this .addKeyListener ()
Original file line number Diff line number Diff line change @@ -124,8 +124,8 @@ export default class QuestionModel {
124124 this . placeholder = 'yyyy-mm-dd'
125125 }
126126
127- if ( this . multiple ) {
128- this . answer = [ ]
127+ if ( this . multiple && ! Array . isArray ( this . answer ) ) {
128+ this . answer = this . answer ? [ this . answer ] : [ ]
129129 }
130130 }
131131
You can’t perform that action at this time.
0 commit comments