Skip to content

Commit 93bad19

Browse files
committed
Add new "autofocus" prop
1 parent b31edb0 commit 93bad19

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/components/FlowForm.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
v-bind:reverse="reverse"
1717
v-bind:disabled="disabled"
1818
v-on:disable="setDisabled"
19+
v-bind:autofocus="autofocus"
1920
/>
2021

2122
<slot></slot>
@@ -170,7 +171,11 @@
170171
default: false
171172
},
172173
timerStartStep: [String, Number],
173-
timerStopStep: [String, Number]
174+
timerStopStep: [String, Number],
175+
autofocus: {
176+
type: Boolean,
177+
default: true
178+
}
174179
},
175180
176181
mixins: [
@@ -634,7 +639,7 @@
634639
const q = this.activeQuestionComponent()
635640
636641
if (q) {
637-
q.focusField()
642+
this.autofocus && q.focusField()
638643
this.activeQuestionIndex = q.question.index
639644
} else if (this.isOnLastStep) {
640645
// No more questions left - set "completed" to true

src/components/FlowFormQuestion.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@
150150
disabled: {
151151
type: Boolean,
152152
default: false
153+
},
154+
autofocus: {
155+
type: Boolean,
156+
default: true
153157
}
154158
},
155159
@@ -166,7 +170,7 @@
166170
},
167171
168172
mounted() {
169-
this.focusField()
173+
this.autofocus && this.focusField()
170174
171175
this.dataValue = this.question.answer
172176
@@ -188,7 +192,7 @@
188192
},
189193
190194
onAnimationEnd() {
191-
this.focusField()
195+
this.autofocus && this.focusField()
192196
},
193197
194198
shouldFocus() {

0 commit comments

Comments
 (0)