orestbida / cookieconsent

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

[Feat v3]: setting to hide the consent modal by default #567

Closed codewithzac closed 9 months ago

codewithzac commented 9 months ago

Description

I'd like a way to be able to set the visibility of the default consent modal to hidden. This is so I can load the consent settings and generally make it possible to consent to or reject categories, but only automatically show the consent modal when I have to offer the option to do so.

Countries like Australia and New Zealand (currently) have no specific requirement to show a consent prompt or collect consent information, but I'd like to be able to offer users in those countries the option to do so if they want.

I've got a workaround using the root config option to put the modal in a hidden div for those countries, but it feels a bit hacky. Is there a better way / could this be another config option?

Proposed solution

Add a config option called "visibility" that controls whether the modal is displayed when no valid consent has been set. Default value should be "show", but it should also be possible to "hide" the modal.

Subsequently calling the CookieConsent.show(); or CookieConsent.showPreferences(); functions should show the relevant prompt.

Additional details

No response

orestbida commented 9 months ago

Hi @codewithzac, you can achieve this by setting autoShow to false, as explained in the docs.

codewithzac commented 9 months ago

Hi @orestbida - thank you so much for the quick reply! I went over the documentation looking for something like this I don't know how many times ... I have no idea how I missed that option. Sorry for clogging up your issue tracker with a support request ;)