Skip to content

Commit

Permalink
Fix sizing issue with captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
JhumanJ committed Aug 8, 2024
1 parent 2f0f872 commit 7888990
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions client/components/open/forms/OpenForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</div>
<form
v-else-if="dataForm"
:style="computedStyle"
@submit.prevent=""
>
<template v-if="form.show_progress_bar">
Expand Down Expand Up @@ -77,6 +78,8 @@
ref="hcaptcha"
:sitekey="hCaptchaSiteKey"
:theme="darkMode?'dark':'light'"
@opened="setMinHeight(500)"
@closed="setMinHeight(0)"
/>
<has-error
:form="dataForm"
Expand Down Expand Up @@ -179,6 +182,7 @@ export default {
dataForm,
recordsStore,
workingFormStore,
isIframe: useIsIframe(),
draggingNewBlock: computed(() => workingFormStore.draggingNewBlock),
pendingSubmission: pendingSubmission(props.form)
}
Expand All @@ -191,6 +195,7 @@ export default {
* Used to force refresh components by changing their keys
*/
isAutoSubmit: false,
minHeight: 0
}
},
Expand Down Expand Up @@ -290,6 +295,11 @@ export default {
}
})
return data
},
computedStyle() {
return {
...this.minHeight ? {minHeight: this.minHeight + 'px'} : {}
}
}
},
Expand Down Expand Up @@ -452,7 +462,7 @@ export default {
nextPage() {
if (this.adminPreview || this.urlPrefillPreview) {
this.currentFieldGroupIndex += 1
window.scrollTo({ top: 0, behavior: 'smooth' })
window.scrollTo({top: 0, behavior: 'smooth'})
return false
}
const fieldsToValidate = this.currentFields.map(f => f.id)
Expand All @@ -463,28 +473,28 @@ export default {
this.dataForm.busy = false
window.scrollTo({top: 0, behavior: 'smooth'})
}).catch(error => {
console.error(error)
if (error && error.data && error.data.message) {
useAlert().error(error.data.message)
}
this.dataForm.busy = false
})
console.error(error)
if (error && error.data && error.data.message) {
useAlert().error(error.data.message)
}
this.dataForm.busy = false
})
return false
},
isFieldHidden(field) {
return (new FormLogicPropertyResolver(field, this.dataFormValue)).isHidden()
},
getTargetFieldIndex(currentFieldPageIndex){
getTargetFieldIndex(currentFieldPageIndex) {
let targetIndex = 0
if (this.currentFieldGroupIndex > 0) {
for (let i = 0; i < this.currentFieldGroupIndex; i++) {
targetIndex += this.fieldGroups[i].length
}
targetIndex += currentFieldPageIndex
} else {
targetIndex = currentFieldPageIndex
if (this.currentFieldGroupIndex > 0) {
for (let i = 0; i < this.currentFieldGroupIndex; i++) {
targetIndex += this.fieldGroups[i].length
}
return targetIndex
targetIndex += currentFieldPageIndex
} else {
targetIndex = currentFieldPageIndex
}
return targetIndex
},
handleDragDropped(data) {
if (data.added) {
Expand All @@ -497,6 +507,18 @@ export default {
const newTargetIndex = this.getTargetFieldIndex(data.moved.newIndex)
this.workingFormStore.moveField(oldTargetIndex, newTargetIndex)
}
},
setMinHeight(minHeight) {
if (!this.isIframe) {
return
}
this.minHeight = minHeight
// Trigger window iframe resize
try {
window.parentIFrame.size()
} catch (e) {
console.error(e)
}
}
}
}
Expand Down

0 comments on commit 7888990

Please sign in to comment.