orestbida / cookieconsent

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js
https://playground.cookieconsent.orestbida.com/
MIT License
4.05k stars 416 forks source link

[Bug]: disablePageInteraction is not working #744

Open fmonsalvo opened 3 weeks ago

fmonsalvo commented 3 weeks ago

Expected Behavior

According to the documentation by setting disablePageInteraction to true, an overlay blocks any interaction with the underlying page until the cookie consent has been interacted with.

Current Behavior

The overlay is not showing and scrolling is enabled.

Steps to reproduce

Create a NextJs app, install vanilla cookie consent, configure it like this:

useEffect(() => {
    CookieConsent.run({
      autoShow: false,
      disablePageInteraction: true,
      categories: {
        necessary: {
          enabled: true,
          readOnly: true,
        },
        functional: {
          enabled: true,
        },
        analytics: {
          enabled: true,
        },
        performance: {
          enabled: true,
        },
        advertisement: {
          enabled: true,
        },
        uncategorized: {
          enabled: true,
        },
      },
      onConsent: ({ cookie }) => {
        setConsent(cookie);
      },
      guiOptions: {
        consentModal: {
          layout: "cloud inline",
        },
        preferencesModal: {
          flipButtons: true,
        },
      },
      language: {
        default: "en",
        translations: {
          en: {
            consentModal: {},
            preferencesModal: {
              title: "Customize Consent Preferences",
              acceptAllBtn: "Accept All Cookies",
              savePreferencesBtn: "Save My Preferences",
              sections: enCookieConsentSections,
            },
          },
        },
      },
    });
  }, []);

Launch the application, scroll is enabled.

Proposed fix or additional info.

No response

Version

3.0.1

On which browser do you see the issue?

Firefox, Chrome, Safari

orestbida commented 4 days ago

The overlay is set only if the consentModal is visible.

Noticed you have set autoShow: false, so I assume you are manually calling the .show() method.

Works fine on my end.