Skip to content

[FIX] website: Save cookie consent with primary button style#244875

Closed
fw-bot wants to merge 1 commit intoodoo:19.0from
odoo-dev:19.0-19.0-opw-5484578-cookies_consent-sben-492336-fw
Closed

[FIX] website: Save cookie consent with primary button style#244875
fw-bot wants to merge 1 commit intoodoo:19.0from
odoo-dev:19.0-19.0-opw-5484578-cookies_consent-sben-492336-fw

Conversation

@fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Jan 20, 2026

Steps to reproduce:

  1. Enable the Cookies Bar in website settings.
  2. Go to the website and enter Edit mode.
  3. Select the Cookie Bar and change the button "I agree" style shape to "Default" (this applies the .btn-primary class). & Save
  4. Accept the cookies & refresh

-> The cookie bar appears again because the consent was not saved.

Cause:

The CookiesBar widget inherits from the generic Popup widget. The Popup class defines a default behavior for elements with the .btn-primary class: clicking them triggers onBtnPrimaryClick, which closes the popup.

By default, the cookie bar button uses .btn-outline-primary, avoiding this behavior. However, when the user changes the style to "Default", the button receives the .btn-primary class. Consequently, the parent Popup handler is triggered. It closes the modal prematurely, interrupting the CookiesBar's specific logic (specifically onAcceptClick),So onHideModal won't be called inside the function, and as a result, the user's consent cookie is never written.

Solution:

Override the event to avoid side effects on hide.

opw-5484578


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #243562

@robodoo
Copy link
Contributor

robodoo commented Jan 20, 2026

Pull request status dashboard

@robodoo robodoo added forwardport This PR was created by @fw-bot conflict There was an error while creating this forward-port PR labels Jan 20, 2026
@fw-bot
Copy link
Contributor Author

fw-bot commented Jan 20, 2026

@sben-odoo @robinlej cherrypicking of pull request #243562 failed.

stdout:

Auto-merging addons/website/static/src/interactions/cookies/cookies_bar.js
CONFLICT (content): Merge conflict in addons/website/static/src/interactions/cookies/cookies_bar.js

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

⚠️ after resolving this conflict, you will need to merge it via @robodoo.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

Steps to reproduce:
===================
1. Enable the Cookies Bar in website settings.
2. Go to the website and enter Edit mode.
3. Select the Cookie Bar and change the button "I agree" style shape to
"Default"  (this applies the `.btn-primary` class). & Save
4. Accept the cookies & refresh

-> The cookie bar appears again because the consent was not saved.

Cause:
======
The `CookiesBar` widget inherits from the generic `Popup` widget.
The `Popup` class defines a default behavior for elements with the
`.btn-primary` class: clicking them triggers `onBtnPrimaryClick`,
which closes the popup.

By default, the cookie bar button uses `.btn-outline-primary`, avoiding
this behavior. However, when the user changes the style to "Default",
the button receives the `.btn-primary` class. Consequently, the
parent `Popup` handler is triggered. It closes the modal prematurely,
interrupting the `CookiesBar`'s specific logic (specifically
`onAcceptClick`),So onHideModal won't be called inside the function,
and as a result, the user's consent cookie is never written.

Solution:
=========
Override the event to avoid side effects on hide.

opw-5484578

X-original-commit: dde9485
@sben-odoo sben-odoo force-pushed the 19.0-19.0-opw-5484578-cookies_consent-sben-492336-fw branch from dacc07b to 0e89112 Compare January 21, 2026 11:18
@sben-odoo
Copy link
Contributor

robodoo r+

@C3POdoo C3POdoo requested a review from a team January 21, 2026 11:36
@robinlej
Copy link
Contributor

@robodoo r+

@robodoo
Copy link
Contributor

robodoo commented Jan 21, 2026

This PR is already reviewed, reviewing it again is useless.

@robodoo robodoo closed this in efac9f4 Jan 21, 2026
snrav-odoo pushed a commit to odoo-dev/odoo that referenced this pull request Jan 22, 2026
Steps to reproduce:
===================
1. Enable the Cookies Bar in website settings.
2. Go to the website and enter Edit mode.
3. Select the Cookie Bar and change the button "I agree" style shape to
"Default"  (this applies the `.btn-primary` class). & Save
4. Accept the cookies & refresh

-> The cookie bar appears again because the consent was not saved.

Cause:
======
The `CookiesBar` widget inherits from the generic `Popup` widget.
The `Popup` class defines a default behavior for elements with the
`.btn-primary` class: clicking them triggers `onBtnPrimaryClick`,
which closes the popup.

By default, the cookie bar button uses `.btn-outline-primary`, avoiding
this behavior. However, when the user changes the style to "Default",
the button receives the `.btn-primary` class. Consequently, the
parent `Popup` handler is triggered. It closes the modal prematurely,
interrupting the `CookiesBar`'s specific logic (specifically
`onAcceptClick`),So onHideModal won't be called inside the function,
and as a result, the user's consent cookie is never written.

Solution:
=========
Override the event to avoid side effects on hide.

opw-5484578

closes odoo#244875

X-original-commit: dde9485
Signed-off-by: Robin Lejeune (role) <role@odoo.com>
Signed-off-by: Saif Allah Ben Khalil (sben) <sben@odoo.com>
jlong1307 pushed a commit to odoo-dev/odoo that referenced this pull request Jan 26, 2026
Steps to reproduce:
===================
1. Enable the Cookies Bar in website settings.
2. Go to the website and enter Edit mode.
3. Select the Cookie Bar and change the button "I agree" style shape to
"Default"  (this applies the `.btn-primary` class). & Save
4. Accept the cookies & refresh

-> The cookie bar appears again because the consent was not saved.

Cause:
======
The `CookiesBar` widget inherits from the generic `Popup` widget.
The `Popup` class defines a default behavior for elements with the
`.btn-primary` class: clicking them triggers `onBtnPrimaryClick`,
which closes the popup.

By default, the cookie bar button uses `.btn-outline-primary`, avoiding
this behavior. However, when the user changes the style to "Default",
the button receives the `.btn-primary` class. Consequently, the
parent `Popup` handler is triggered. It closes the modal prematurely,
interrupting the `CookiesBar`'s specific logic (specifically
`onAcceptClick`),So onHideModal won't be called inside the function,
and as a result, the user's consent cookie is never written.

Solution:
=========
Override the event to avoid side effects on hide.

opw-5484578

closes odoo#244875

X-original-commit: dde9485
Signed-off-by: Robin Lejeune (role) <role@odoo.com>
Signed-off-by: Saif Allah Ben Khalil (sben) <sben@odoo.com>
KazuakiWatanabe pushed a commit to KazuakiWatanabe/odoo_local that referenced this pull request Jan 27, 2026
Steps to reproduce:
===================
1. Enable the Cookies Bar in website settings.
2. Go to the website and enter Edit mode.
3. Select the Cookie Bar and change the button "I agree" style shape to
"Default"  (this applies the `.btn-primary` class). & Save
4. Accept the cookies & refresh

-> The cookie bar appears again because the consent was not saved.

Cause:
======
The `CookiesBar` widget inherits from the generic `Popup` widget.
The `Popup` class defines a default behavior for elements with the
`.btn-primary` class: clicking them triggers `onBtnPrimaryClick`,
which closes the popup.

By default, the cookie bar button uses `.btn-outline-primary`, avoiding
this behavior. However, when the user changes the style to "Default",
the button receives the `.btn-primary` class. Consequently, the
parent `Popup` handler is triggered. It closes the modal prematurely,
interrupting the `CookiesBar`'s specific logic (specifically
`onAcceptClick`),So onHideModal won't be called inside the function,
and as a result, the user's consent cookie is never written.

Solution:
=========
Override the event to avoid side effects on hide.

opw-5484578

closes odoo#244875

X-original-commit: dde9485
Signed-off-by: Robin Lejeune (role) <role@odoo.com>
Signed-off-by: Saif Allah Ben Khalil (sben) <sben@odoo.com>
@fw-bot fw-bot deleted the 19.0-19.0-opw-5484578-cookies_consent-sben-492336-fw branch January 28, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants