From e7594d81b686ca02a0c66acddedf6689d98e42e8 Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Tue, 5 Sep 2023 01:35:48 +0300 Subject: [PATCH] fix signature step next button disabled --- app/javascript/submission_form/form.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index 04f733b8..86f0696c 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -421,7 +421,8 @@ export default { isCompleted: false, isFormVisible: true, currentStep: 0, - isSubmitting: false + isSubmitting: false, + recalculateButtonDisabledKey: '' } }, computed: { @@ -435,9 +436,13 @@ export default { return this.currentField.type === 'checkbox' && this.currentStepFields.every((e) => !e.name) && this.currentStepFields.length > 4 }, isButtonDisabled () { - return this.isSubmitting || + if (this.recalculateButtonDisabledKey) { + return this.isSubmitting || (this.currentField.required && ['image', 'file'].includes(this.currentField.type) && !this.values[this.currentField.uuid]?.length) || (this.currentField.required && this.currentField.type === 'signature' && !this.values[this.currentField.uuid]?.length && this.$refs.currentStep && !this.$refs.currentStep.isSignatureStarted) + } else { + return false + } }, currentField () { return this.currentStepFields[0] @@ -485,6 +490,10 @@ export default { scrollbox.parentNode.style.maxHeight = '-webkit-fill-available' }) } + + this.$nextTick(() => { + this.recalculateButtonDisabledKey = Math.random() + }) }, methods: { t, @@ -492,6 +501,8 @@ export default { this.currentStep = this.stepFields.indexOf(step) this.$nextTick(() => { + this.recalculateButtonDisabledKey = Math.random() + if (scrollToArea) { this.$refs.areas.scrollIntoField(step[0]) }