From ca10ad3c2ad1a652bfb6ae25d3c219035db5678f Mon Sep 17 00:00:00 2001 From: "Guillaume (gdi)" Date: Fri, 9 Jun 2023 12:45:22 +0000 Subject: [PATCH] [FIX] website: ignore carousel slides for history step When you drop a block containing a carousel, you can change the slide. Unfortunately, in edit mode, changing the slide creates a step in the history (you slide in the other direction by pressing CTRL-Z). This is not what you want. task-3356629 closes odoo/odoo#130417 X-original-commit: 5c68489c4220fe50c26168f2fb98546626b36e78 Signed-off-by: Colin Louis (loco) Signed-off-by: Guillaume Dieleman (gdi) --- .../static/src/js/content/snippets.animation.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 40f025790d9..9537cfeb404 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -459,6 +459,15 @@ registry.slider = publicWidget.Widget.extend({ // Initialize carousel and pause if in edit mode. this.$el.carousel(this.editableMode ? 'pause' : undefined); $(window).on('resize.slider', debounce(() => this._computeHeights(), 250)); + if (this.editableMode) { + // Prevent carousel slide to be an history step. + this.$el.on("slide.bs.carousel", () => { + this.options.wysiwyg.odooEditor.observerUnactive(); + }); + this.$el.on("slid.bs.carousel", () => { + this.options.wysiwyg.odooEditor.observerActive(); + }); + } return this._super.apply(this, arguments); }, /** @@ -475,6 +484,7 @@ registry.slider = publicWidget.Widget.extend({ $(el).css("min-height", ""); }); $(window).off('.slider'); + this.$target.off('.carousel'); }, //--------------------------------------------------------------------------