From be1d93edcfbd496c22a7c988b4570858a3d06c2c Mon Sep 17 00:00:00 2001 From: Antoine Guenet <age@odoo.com> Date: Mon, 28 Nov 2022 14:33:17 +0000 Subject: [PATCH] [FIX] website: properly revert slider on break unbreakable When breaking a page from a Carousel or other slider snippet (eg by hitting the backspace key at the beginning of a page), the editor's history gets reverted but ends up applying the `active` class to all pages. This is due is some way to the `_computeHeights` method of the slider snippet, which applied the class to all pages to observe their heights, then put them back in place. It seems in the labyrinth of ticks the history step somehow started from a place where every page was active, so we reverted back to that. The point where these classes were applied should have never been observed in the first place since it's purely technical. Not observing it fixes the bug. task-3081259 closes odoo/odoo#106696 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com> --- addons/website/static/src/js/content/snippets.animation.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 4d08d07dc059..84f678779d23 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -475,15 +475,19 @@ registry.slider = publicWidget.Widget.extend({ var maxHeight = 0; var $items = this.$('.carousel-item'); $items.css('min-height', ''); - _.each($items, function (el) { + _.each($items, el => { var $item = $(el); var isActive = $item.hasClass('active'); + this.options.wysiwyg && this.options.wysiwyg.odooEditor.observerUnactive('_computeHeights'); $item.addClass('active'); + this.options.wysiwyg && this.options.wysiwyg.odooEditor.observerActive('_computeHeights'); var height = $item.outerHeight(); if (height > maxHeight) { maxHeight = height; } + this.options.wysiwyg && this.options.wysiwyg.odooEditor.observerUnactive('_computeHeights'); $item.toggleClass('active', isActive); + this.options.wysiwyg && this.options.wysiwyg.odooEditor.observerActive('_computeHeights'); }); $items.css('min-height', maxHeight); }, -- GitLab