klaro-org / klaro-js

Klaro Privacy Manager. An open-source, privacy-friendly & compliant consent manager for your website.
https://klaro.org
Other
1.18k stars 250 forks source link

JS cookie button not opening consent configuration when not accepted or declined before #312

Open futurewebEubling opened 3 years ago

futurewebEubling commented 3 years ago

HTML of JS "klaro.show()" cookie button:

<a class="button is-success" onclick="return klaro.show();">Cookies</a>

Steps to reproduce

Open any website with Klaro cookie consent manager and try to open the configuration "cookie-modal" by clicking the JS "klaro.show()" button before accepting or declining the "cookie-notice". For example: https://www.futureweb.at/ (button "Cookies" at the very bottom right)

Current behavior

"cookie-modal" configuration is not opening by clicking the klaro.show() JS button as long as you have not accepted or declined all cookies in "cookie-notice".

Expected behavior

The "cookie-modal" configuration should open any time by clicking the klaro.show() JS button even if you have not already accepted or declined the cookie-notice.

adewes commented 3 years ago

Hi @futurewebEubling! You can enforce the opening of the modal using

// using the default config
klaro.show(undefined, {modal: true})
// using a specific config
klaro.show(config, {modal: true})

We don't automatically open the modal as in some cases you want to trigger the showing of the notice manually, hence we do not always open the modal with the show() call, unless the modal option is explicitly given. Does that solve your issue?

futureweb commented 3 years ago

Hi @adewes, this is a rather inconsistent behavior of the show() call.

If you call show() when no Consent Selection has yet been made:

When calling show() after making a selection:

So calling the Function the same way results in a different behaviour regarding the current State of the App. IMHO a called Function should always have consistant behavior, don't you think ... ? ;-)

Just my 2 Cents on this ;-)

bye from sunny Austria Andreas

adewes commented 3 years ago

Good points @futureweb! Do you think showNotice() and showModal() functions would be better?

futureweb commented 3 years ago

Hey @adewes, guess that would be one way to ensure a consistant app behaviour regardless of the current State of the App. AFAIK Usercentrics and other CMPs also implemented it that way ... ;-) One could leave show() as (pseudo intelligent) Wrapper to the new Calls for legacy compatibility ... with a short Notice of it's special behaviour in the Docs. (Show Notice while no selection has been made, Show Modal after selection has been made) bye from sunny Austria Andreas