whitecube / laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Accept buttons not working on first click

nlukic97 opened this issue · comments

I have noticed scenarious where clicking on "Accept all" or "Accept essentials" will not work (popup box remains open). In such cases, users have to click a second time for the popup box to close.

This issue was the placement of @cookieconsentscripts - if there are other script tags of a larger size above it, the cookie box will open without the actual laravel-cookie-consent javascript being loaded, so clicking on it will throw an undefined error:

image

The solution is to move @cookieconsentscripts above all other script tags to ensure it loads first.

However, I would suggest displaying the popup box after the event DOMContentLoaded is fired

@nlukic97 I tried your suggestion (script at the very top), but still no luck for me.

@toonvandenbos Any input on the proposition for "after the event DOMContentLoaded is fired"

I'm not against the idea of masking the DOM element until the document is fully loaded when JavaScript is enabled since the whole point of this package is to work when JS is not enabled too. If somebody has some time to work on a PR having these constraints in mind, that would be helpful! Thanks :)