cookieconsent
cookieconsent copied to clipboard
[Bug]: Clicking Save Preferences button rejects all services regardless of toggle state
Expected Behavior
Should save the current service selection.
Current Behavior
All services are rejected and fire their onReject event.
Steps to reproduce
See this StackBlitz for a minimal repro: https://stackblitz.com/edit/stackblitz-starters-xtbkbf?file=index.js
- Click Open Preview in new tab icon to open in new window that will retain cookies on reload.
- Open F12 developer tools to see console.log entries.
- Click Accept all to accept all categories/services.
- Press F5 to reload the page.
- Click the Show preferences modal button to open the preferences window.
- Expand the Analytics cookies section to see that Service1 and Service2 are active.
- Click Save preferences to save the current selection without making any changes.
Proposed fix or additional info.
See PR: https://github.com/orestbida/cookieconsent/pull/701
Version
3.0.1
On which browser do you see the issue?
Firefox, Chrome
I think I've found the cause of this issue. The retrieveState method of api.js currently sets the _enabledServices before _acceptedServices so the enabled services don't include services read from the cc-cookie. I think reversing this order is sufficient to fix it.
See pull request #701