Sunday, February 11, 2024
1 change · 17.0
Resolved issues and error corrections
This fix resolves issues with carousel slides not updating correctly and slides not being removable when carousel display options (like height or visibility) are changed. The problem occurred because event listeners were being removed too broadly, affecting carousel functionality. The fix makes these listeners more specific so only the necessary ones are removed, preserving carousel behavior when options are adjusted.
Original PR description
In order to not add steps in the history when changing the slides of a carousel, commit [1] added listeners that would deactivate the observer when sliding and reactivate it when the slide is over,…
In order to not add steps in the history when changing the slides of a carousel, commit [1] added listeners that would deactivate the observer when sliding and reactivate it when the slide is over, in the `slider` public widget. These listeners are then removed at destroy. However, the way they are removed breaks some of the carousel behaviors: - Drop a "Carousel" snippet. - Change any "Carousel" option (so not a "Slide" one). For example, set the "Height" to 50% or add a conditional visibility. - Slide the carousel (with any arrow). => The slide number did not update correctly. - Remove a slide with the "-" button. => The slide was not removed. It happens because, when this widget is destroyed, it removes all the `.carousel` listeners, which means that it also removes the listeners added at the `Carousel` options start. And since the widget is destroyed and restarted every time an option is changed, but the "Carousel" options are started only once at the beginning, the removed listeners are never added back (until the next start of the options). This commit adds an id to the events managing the sliding history, to make them more specific, in order to only remove these ones when the widget is destroyed. [1]: https://github.com/odoo/odoo/commit/14bc1a9bd1ebdec3b73e268450267320b79d01cd opw-3675019 Forward-Port-Of: odoo/odoo#153575 Forward-Port-Of: odoo/odoo#153102