Skip to content

Browser unload warning when Snaptcha is enabled #2668

@redburn

Description

@redburn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions