formie
formie copied to clipboard
Browser unload warning when Snaptcha is enabled
Describe the bug
Similar to #1610 but with Snaptcha: when a form has Snaptcha enabled, a browser prompt fires onunload asking to confirm leaving the site as there may be unsaved changes. Disabling Snaptcha for the form removes the prompt.
Happens with reloading of tokens via refreshForCache():
{{ craft.formie.renderForm('myForm') }}
{% js %}
document.addEventListener('onFormieInit', (event) => {
let Formie = event.detail.formie;
Formie.refreshForCache(event.detail.formId);
});
{% endjs %}
As well as without:
{{ craft.formie.renderForm('myForm') }}
Incidentally, refreshForCache() always seem to fire two refresh-tokens AJAX requests (for a single form).
Steps to reproduce
- Enable Snaptcha integration in a form
- Visit a page that embeds the form
- Leave the page and receive a "Leave site?" browser prompt
Form settings
- Multi-page form: No
- Submission Method: Ajax or Page Reload (either)
- Client-side Validation: Yes or No (either)
- Custom Form Templates: Yes or No (either)
Craft CMS version
5.8.21
Plugin version
3.1.6
Multi-site?
No
Additional context
No response