odoo/odoo#244875

Created by fw-bot
Merged at efac9f4cd572856c2b72bc61349abb3915ac6063

Statuses:

label
odoo-dev:19.0-19.0-opw-5484578-cookies_consent-sben-492336-fw
head
0e89112648760388aca7be63cb328be175c38be9
merged
2 weeks ago by Saif Allah Ben Khalil (sben)
odoo/odoo
saas-18.2 #243562
saas-18.3 #244836
saas-18.4 #244855
19.0 #244875
saas-19.1 #245138
master #245148

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

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