diff --git a/client/components/forms/FileInput.vue b/client/components/forms/FileInput.vue index 4d904dc7..83936896 100644 --- a/client/components/forms/FileInput.vue +++ b/client/components/forms/FileInput.vue @@ -175,7 +175,7 @@ export default { } }, openFileUpload () { - if (this.disabled) return + if (this.disabled || !this.$refs['actual-input']) return this.$refs['actual-input'].click() }, manualFileUpload (e) { diff --git a/client/components/forms/components/VSwitch.vue b/client/components/forms/components/VSwitch.vue index 28d29451..7b9c225b 100644 --- a/client/components/forms/components/VSwitch.vue +++ b/client/components/forms/components/VSwitch.vue @@ -13,10 +13,10 @@ const props = defineProps({ modelValue: { type: Boolean, default: false }, disabled: { type: Boolean, default: false } }) -const emits = defineEmits(['update:modelValue']) +const emit = defineEmits(['update:modelValue']) const onClick = () => { if (props.disabled) return - emits('update:modelValue', !props.modelValue) + emit('update:modelValue', !props.modelValue) } diff --git a/client/components/global/Modal.vue b/client/components/global/Modal.vue index 971ef87b..39351a97 100644 --- a/client/components/global/Modal.vue +++ b/client/components/global/Modal.vue @@ -71,7 +71,7 @@ const props = defineProps({ } }) -const emits = defineEmits(['close']) +const emit = defineEmits(['close']) useHead({ bodyAttrs: { @@ -152,7 +152,7 @@ const onLeave = (el, done) => { const close = () => { if (props.closeable) { - emits('close') + emit('close') } } diff --git a/client/components/global/transitions/Collapsible.vue b/client/components/global/transitions/Collapsible.vue index 52d27f1f..ec3512ff 100644 --- a/client/components/global/transitions/Collapsible.vue +++ b/client/components/global/transitions/Collapsible.vue @@ -17,7 +17,7 @@ const props = defineProps({ modelValue: {type: Boolean}, maxHeight: {type: Number, default: 200}, }) -const emits = defineEmits(['click-away']) +const emit = defineEmits(['click-away']) const motion = ref(null) const collapsible = ref(null) @@ -47,6 +47,6 @@ const onLeave = (el, done) => { } const onClickAway = (event) => { - emits('click-away', event) + emit('click-away', event) } diff --git a/client/pages/forms/[slug]/edit.vue b/client/pages/forms/[slug]/edit.vue index 7b2f6a35..c4eb950e 100644 --- a/client/pages/forms/[slug]/edit.vue +++ b/client/pages/forms/[slug]/edit.vue @@ -33,9 +33,11 @@ const error = ref(null) const formInitialHash = ref(null) function isDirty() { - return formInitialHash.value && - updatedForm.value && - formInitialHash.value !== hash(JSON.stringify(updatedForm?.value?.data() ?? null)) + try { + return formInitialHash.value && updatedForm.value && formInitialHash.value !== hash(JSON.stringify(updatedForm?.value?.data() ?? null)) + } catch (e) { + return false + } } function initUpdatedForm() { diff --git a/client/pages/forms/[slug]/index.vue b/client/pages/forms/[slug]/index.vue index 0637b428..ad8cd48d 100644 --- a/client/pages/forms/[slug]/index.vue +++ b/client/pages/forms/[slug]/index.vue @@ -123,7 +123,11 @@ onMounted(() => { if (process.client) { if (form.value.custom_code) { const scriptEl = document.createRange().createContextualFragment(form.value.custom_code) - document.head.append(scriptEl) + try { + document.head.append(scriptEl) + } catch (e) { + console.error('Error appending custom code', e) + } } if (!isIframe) focusOnFirstFormElement() } @@ -135,22 +139,28 @@ onBeforeRouteLeave((to, from) => { disableDarkMode() }) +const pageMeta = computed(() => { + if (form.value && form.value.is_pro && form.value.seo_meta) { + return form.value.seo_meta + } + return {} +}) useOpnSeoMeta({ title: () => { - if (form && form.value?.is_pro && form.value.seo_meta.page_title) { - return form.value.seo_meta.page_title + if (pageMeta.value.page_title) { + return pageMeta.value.page_title } return form.value ? form.value.title : 'Create beautiful forms' }, description: () => { - if (form && form.value?.is_pro && form.value.seo_meta.page_description) { - return form.value.seo_meta.page_description + if (pageMeta.value.description) { + return pageMeta.value.description } return (form && form.value?.description) ? form.value?.description.substring(0, 160) : null }, ogImage: () => { - if (form && form.value?.is_pro && form.value.seo_meta.page_thumbnail) { - return form.value.seo_meta.page_thumbnail + if (pageMeta.value.page_thumbnail) { + return pageMeta.value.page_thumbnail } return (form && form.value?.cover_picture) ? form.value?.cover_picture : null }, @@ -160,7 +170,7 @@ useOpnSeoMeta({ }) useHead({ titleTemplate: (titleChunk) => { - if (form && form.value?.is_pro && form.value?.seo_meta.page_title) { + if (pageMeta.value.page_title) { // Disable template if custom SEO title return titleChunk } diff --git a/client/pages/home.vue b/client/pages/home.vue index db793054..5d3c76a0 100644 --- a/client/pages/home.vue +++ b/client/pages/home.vue @@ -69,17 +69,21 @@ {{ form.title }} -