formie icon indicating copy to clipboard operation
formie copied to clipboard

Browser unload warning when Snaptcha is enabled

Open redburn opened this issue 1 week ago • 0 comments

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

  1. Enable Snaptcha integration in a form
  2. Visit a page that embeds the form
  3. 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

redburn avatar Dec 18 '25 15:12 redburn