klaro-js icon indicating copy to clipboard operation
klaro-js copied to clipboard

callback is called if I open the modal programmaticaly

Open sowinski opened this issue 5 years ago • 3 comments

Not sure if this is a feature or a bug.

But if I open the modal

window.klaro = Klaro;
window.config = config;
window.klaro.show(config, true)

the callback method configured in my config is fired.

From my point of view this is a bug. Because the state does not change?

sowinski avatar Aug 21 '20 14:08 sowinski

What triggers the callback is not the consent modal but the fact that you initialize a consent manager, which loads the users' consent choices from the local storage or the cookie store and applies them, triggering the callback function for every app (which could then react to the consent choice) and the global callback. This is done in order to give you a way to apply the consent choice the user has made, it will therefore trigger every time a consent manager gets initialized.

Maybe we should make this more clear in the documentation. Does this behavior cause any issues for you? It might be better to think of the callbacks not as functions that react to a given user action, but as functions that are presented with a given consent decision and should make the necessary changes to honor that decision.

So it's not a bug I'd say, it's a feature ;)

adewes avatar Aug 21 '20 17:08 adewes

It would be great if this could be at least clarified in the docs :).

Does this behavior cause any issues for you?

Nothing I can't work around, but it requires at least some changes. Something that might help is to have a 3rd parameter that indicates if this was due to a user change or just the Klaro init. After reworking my application logic I don't need this change anymore though.

boldtrn avatar Nov 10 '20 08:11 boldtrn

Hi @boldtrn, I agree that it might be good to add some more context here, we'll see how we can do this.

adewes avatar Nov 27 '20 14:11 adewes