segmentio / consent-manager

Drop-in consent management plugin for analytics.js
https://segmentio.github.io/consent-manager/
MIT License
341 stars 144 forks source link

implyConsentOnInteraction causes reload when clicking inside banner #256

Closed seanlail closed 2 years ago

seanlail commented 2 years ago

When a user clicks on the SubContent ("Preferences" text) the page reloads. It seems to be because of the implyConsentOnInteraction setting... but according to the docs it should not imply consent when clicking inside the banner.

Example config:

window.consentManagerConfig = ({ doNotTrack, inEU, preferences, React }) => {
  const initialTrack = doNotTrack() !== true;

  return {
    bannerActionsBlock: (props) =>
      React.createElement("button", { onclick: () => props.acceptAll() }, "OK"),
    bannerContent: React.createElement("span", null, "This site uses cookies"),
    bannerSubContent: "Preferences",
    bannerHideCloseButton: true,
    cancelDialogTitle: "Are you sure you want to cancel?",
    cancelDialogContent: "Your preferences have not been saved.",
    container: "#segment-cookies",
    cookieName: "tracking-preferences",
    defaultDestinationBehavior: "enable",
    implyConsentOnInteraction: true,
    initialPreferences: {
      functional: initialTrack,
      marketingAndAnalytics: initialTrack,
      advertising: initialTrack,
    },
    preferencesDialogContent: "",
    preferencesDialogTitle: "Preferences",
    shouldRequireConsent: inEU,
    writeKey: "<segment-key-goes-here>",
  };
};
edsonjab commented 2 years ago

Hi @seanlail thanks for your report, we start looking into this

edsonjab commented 2 years ago

Hi @seanlail we was checking your report and we can't replicate the issue, I created a project with your configuration of ConsentManager and works like expected, could you share a sandbox or your framework that you used or your project configuration to replicate exactly like you the issue please.

seanlail commented 2 years ago

@edsonjab Here's a repo to show the issue: https://github.com/seanlail/segment-cm-issue-256

Create .env.local and set the NEXT_PUBLIC_SEGMENT_APIKEY=<a valid key> to run it.

edsonjab commented 2 years ago

Hi @seanlail I saw your repo and I put this validation on your code and works for me, could you try this please? image

seanlail commented 2 years ago

Hi @edsonjab, even with that change I get the same issue. When I click on Preferences I see the dialog flash before the page reloads.

https://user-images.githubusercontent.com/142589/189179273-067167a8-9150-44f7-82b3-44e506a458db.mov

edsonjab commented 2 years ago

hi @seanlail I already identify in which moment trigger the reload, I'm working on the solution