Fix sizing issue with captcha

This commit is contained in:
Julien Nahum 2024-08-08 12:00:36 +02:00
parent 2f0f87267f
commit 7888990e84
1 changed files with 38 additions and 16 deletions

View File

@ -6,6 +6,7 @@
</div>
<form
v-else-if="dataForm"
:style="computedStyle"
@submit.prevent=""
>
<template v-if="form.show_progress_bar">
@ -77,6 +78,8 @@
ref="hcaptcha"
:sitekey="hCaptchaSiteKey"
:theme="darkMode?'dark':'light'"
@opened="setMinHeight(500)"
@closed="setMinHeight(0)"
/>
<has-error
:form="dataForm"
@ -179,6 +182,7 @@ export default {
dataForm,
recordsStore,
workingFormStore,
isIframe: useIsIframe(),
draggingNewBlock: computed(() => workingFormStore.draggingNewBlock),
pendingSubmission: pendingSubmission(props.form)
}
@ -191,6 +195,7 @@ export default {
* Used to force refresh components by changing their keys
*/
isAutoSubmit: false,
minHeight: 0
}
},
@ -290,6 +295,11 @@ export default {
}
})
return data
},
computedStyle() {
return {
...this.minHeight ? {minHeight: this.minHeight + 'px'} : {}
}
}
},
@ -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)
}
}
}
}