From a589cf9471ddce6c6f494bacb0d19ac4216ed252 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 27 Jun 2024 17:41:08 +0300 Subject: [PATCH] focus field input --- app/javascript/submission_form/form.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index aded8973..ac3ae7a4 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -697,6 +697,7 @@ export default { isFormVisible: this.expand !== false, showFillAllRequiredFields: false, currentStep: 0, + enableScrollIntoField: true, phoneVerifiedValues: {}, orientation: screen?.orientation?.type, isSubmitting: false, @@ -992,10 +993,12 @@ export default { if (!this.isCompleted) { if (scrollToArea) { this.scrollIntoField(step[0]) - - this.$refs.form.querySelector('input[type="date"], input[type="number"], input[type="text"], select')?.focus() } + this.enableScrollIntoField = false + this.$refs.form.querySelector('input[type="date"], input[type="number"], input[type="text"], select')?.focus() + this.enableScrollIntoField = true + if (clickUpload && !this.values[this.currentField.uuid] && ['file', 'image'].includes(this.currentField.type)) { this.$refs.form.querySelector('input[type="file"]')?.click() } @@ -1028,7 +1031,9 @@ export default { } }, scrollIntoField (field) { - return this.$refs.areas.scrollIntoField(field) + if (this.enableScrollIntoField) { + return this.$refs.areas.scrollIntoField(field) + } }, scrollIntoArea (area) { return this.$refs.areas.scrollIntoArea(area)