Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept buttons not working on first click #47

Open
nlukic97 opened this issue May 6, 2024 · 6 comments
Open

Accept buttons not working on first click #47

nlukic97 opened this issue May 6, 2024 · 6 comments

Comments

@nlukic97
Copy link

nlukic97 commented May 6, 2024

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

@patricksebastien
Copy link

@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"

@toonvandenbos
Copy link
Member

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 :)

@nlukic97
Copy link
Author

nlukic97 commented Aug 8, 2024 via email

@szotyi41
Copy link

szotyi41 commented Sep 6, 2024

Same issue with 1.2.3 and 1.2.2

@cookieconsentscripts at the top of the head
@cookieconsentview bottom of the body

It is used in more projects they're working.

window.LaravelCookieConsent is undefined at the console.

In local the head try to loads like this:
<script src="http://localhost:8000:8000/cookie-consent/script?id=051b492e30fe8edd2aa2c23b8f8bb8ae" defer=""></script>

In .env the APP_URL is http://localhost:8000. In live with correct domain also not working.

@patricksebastien
Copy link

@szotyi41 Is there a version without this issue?

@szotyi41
Copy link

szotyi41 commented Sep 6, 2024

In our older site it is working in the same way: https://mvs-systems.com/ (1.2.2)
In our new site it is not working (tried with 1.2.2 and 1.2.3)

Update:
In live mode the script is loaded and the server respond with 200 {"status": "ok"}
After I go to another page in the same site, the cookie bar appears again and again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants