verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
95 stars 73 forks source link

Unwanted browser unload warning when duplicate captcha is enabled #1610

Closed 0xElectric closed 11 months ago

0xElectric commented 12 months ago

Describe the bug

image image

Steps to reproduce

  1. Enable duplicate captcah
  2. render form and test on frontend (reload)

Form settings

Craft CMS version

Craft Pro 4.5.9

Plugin version

2.0.39

Multi-site?

No

Additional context

No response

engram-design commented 12 months ago

Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-4 as 2.0.39".

jwrudzin commented 12 months ago

@engram-design it looks like this is fixed now for forms that aren't cached, but I'm still getting the unload warning when I have cache breaking JS in use. If I comment out the cache busting code, the reload warning goes away.

engram-design commented 11 months ago

@jwrudzin Are you using the brand new refreshForCache JS function, or are you rolling your own? If the latter, ensure that you're refreshing the form's hahed data.

If you're using the former, I might need some more information, as that's not something I can replicate.

jwrudzin commented 11 months ago

@engram-design I'm using the new refreshForCache JS function. I did some additional testing, and running Formie 2.0.39, I get the reload prompt whether the cache busting JS is in place or not. Once I upgrade to dev-craft-4, I do not get the reload prompt without the cache busting JS, but when the cache busting JS is in place I get prompted every time.

Something else to note - when running dev-craft-4 and with the JS cache busting in place, I get the reload prompt whether the duplicate captcha is enabled or not.

This is on a page with 5 total forms. 1 is unique, the other 4 are duplicates of the same form.

Here's my cache busting JS, in case it's helpful (it comes just after the call to renderForm):

% js "https://cdn.polyfill.io/v2/polyfill.js?features=fetch,Promise" %}
{% js %}
    // Formie Cache Busting
    document.addEventListener('onFormieInit', (event) => {
        // Fetch the Form Factory once it's been loaded
        let Formie = event.detail.formie;

        // Refresh the necessary bits that are statically cached (CSRF inputs, captchas, etc)
        Formie.refreshForCache('{{ form.formId }}');
    });
{% endjs %}
jwrudzin commented 11 months ago

@engram-design I just wanted to add, it seems that this is related to the honeypot captcha. When I disable the honeypot captcha (even with the JS captcha and duplicate captcha enabled, and cache bust code in place), the reload warning goes away.

engram-design commented 11 months ago

Ah yes, the Honeypot captcha behaves differently now (it's fixed from not working correctly), which causes this. Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-4 as 2.0.39".

engram-design commented 11 months ago

Fixed in 2.0.40