Skip to content

Commit 7888990

Browse files
committed
Fix sizing issue with captcha
1 parent 2f0f872 commit 7888990

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

client/components/open/forms/OpenForm.vue

+38-16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</div>
77
<form
88
v-else-if="dataForm"
9+
:style="computedStyle"
910
@submit.prevent=""
1011
>
1112
<template v-if="form.show_progress_bar">
@@ -77,6 +78,8 @@
7778
ref="hcaptcha"
7879
:sitekey="hCaptchaSiteKey"
7980
:theme="darkMode?'dark':'light'"
81+
@opened="setMinHeight(500)"
82+
@closed="setMinHeight(0)"
8083
/>
8184
<has-error
8285
:form="dataForm"
@@ -179,6 +182,7 @@ export default {
179182
dataForm,
180183
recordsStore,
181184
workingFormStore,
185+
isIframe: useIsIframe(),
182186
draggingNewBlock: computed(() => workingFormStore.draggingNewBlock),
183187
pendingSubmission: pendingSubmission(props.form)
184188
}
@@ -191,6 +195,7 @@ export default {
191195
* Used to force refresh components by changing their keys
192196
*/
193197
isAutoSubmit: false,
198+
minHeight: 0
194199
}
195200
},
196201
@@ -290,6 +295,11 @@ export default {
290295
}
291296
})
292297
return data
298+
},
299+
computedStyle() {
300+
return {
301+
...this.minHeight ? {minHeight: this.minHeight + 'px'} : {}
302+
}
293303
}
294304
},
295305
@@ -452,7 +462,7 @@ export default {
452462
nextPage() {
453463
if (this.adminPreview || this.urlPrefillPreview) {
454464
this.currentFieldGroupIndex += 1
455-
window.scrollTo({ top: 0, behavior: 'smooth' })
465+
window.scrollTo({top: 0, behavior: 'smooth'})
456466
return false
457467
}
458468
const fieldsToValidate = this.currentFields.map(f => f.id)
@@ -463,28 +473,28 @@ export default {
463473
this.dataForm.busy = false
464474
window.scrollTo({top: 0, behavior: 'smooth'})
465475
}).catch(error => {
466-
console.error(error)
467-
if (error && error.data && error.data.message) {
468-
useAlert().error(error.data.message)
469-
}
470-
this.dataForm.busy = false
471-
})
476+
console.error(error)
477+
if (error && error.data && error.data.message) {
478+
useAlert().error(error.data.message)
479+
}
480+
this.dataForm.busy = false
481+
})
472482
return false
473483
},
474484
isFieldHidden(field) {
475485
return (new FormLogicPropertyResolver(field, this.dataFormValue)).isHidden()
476486
},
477-
getTargetFieldIndex(currentFieldPageIndex){
487+
getTargetFieldIndex(currentFieldPageIndex) {
478488
let targetIndex = 0
479-
if (this.currentFieldGroupIndex > 0) {
480-
for (let i = 0; i < this.currentFieldGroupIndex; i++) {
481-
targetIndex += this.fieldGroups[i].length
482-
}
483-
targetIndex += currentFieldPageIndex
484-
} else {
485-
targetIndex = currentFieldPageIndex
489+
if (this.currentFieldGroupIndex > 0) {
490+
for (let i = 0; i < this.currentFieldGroupIndex; i++) {
491+
targetIndex += this.fieldGroups[i].length
486492
}
487-
return targetIndex
493+
targetIndex += currentFieldPageIndex
494+
} else {
495+
targetIndex = currentFieldPageIndex
496+
}
497+
return targetIndex
488498
},
489499
handleDragDropped(data) {
490500
if (data.added) {
@@ -497,6 +507,18 @@ export default {
497507
const newTargetIndex = this.getTargetFieldIndex(data.moved.newIndex)
498508
this.workingFormStore.moveField(oldTargetIndex, newTargetIndex)
499509
}
510+
},
511+
setMinHeight(minHeight) {
512+
if (!this.isIframe) {
513+
return
514+
}
515+
this.minHeight = minHeight
516+
// Trigger window iframe resize
517+
try {
518+
window.parentIFrame.size()
519+
} catch (e) {
520+
console.error(e)
521+
}
500522
}
501523
}
502524
}

0 commit comments

Comments
 (0)