[FIX] web_editor, website: fix undo after enabling hover effects.
Steps to reproduce the bug: - In Website edit mode, drag & drop a text-image snippet onto the page. - Click on the image of the snippet. - In the image options, select "On Hover" for the "Animation" option. - Click on the "Undo" button in the top bar of the editor panel. - Bug: The "Animation" option has not been deactivated, the "Hover Effect" is still present when hovering over the image. task-3495241 closes odoo/odoo#134979 Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
This commit is contained in:
@@ -6754,6 +6754,13 @@ registry.ImageTools = ImageHandlerOption.extend({
|
||||
}
|
||||
}
|
||||
await this._reapplyCurrentShape();
|
||||
// When the hover effects are first activated from the "animationMode"
|
||||
// function of the "WebsiteAnimate" class, the history was paused to
|
||||
// avoid recording intermediate steps. That's why we unpause it here.
|
||||
if (this.firstHoverEffect) {
|
||||
this.options.wysiwyg.odooEditor.historyUnpauseSteps();
|
||||
delete this.firstHoverEffect;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @see this.selectClass for parameters
|
||||
@@ -6801,6 +6808,7 @@ registry.ImageTools = ImageHandlerOption.extend({
|
||||
shapeImgSquareWidget.getParent().close(); // FIXME remove this ugly hack asap
|
||||
}
|
||||
// Add the "Overlay" hover effect to the shape.
|
||||
this.firstHoverEffect = true;
|
||||
const hoverEffectOverlayWidget = this._requestUserValueWidgets("hover_effect_overlay_opt")[0];
|
||||
hoverEffectOverlayWidget.enable();
|
||||
hoverEffectOverlayWidget.getParent().close(); // FIXME remove this ugly hack asap
|
||||
|
||||
@@ -1776,7 +1776,7 @@ registry.ImageShapeHoverEffet = publicWidget.Widget.extend({
|
||||
* @private
|
||||
*/
|
||||
_onMouseEnter() {
|
||||
if (!this.originalImgSrc) {
|
||||
if (!this.originalImgSrc || !this.$target[0].dataset.hoverEffect) {
|
||||
return;
|
||||
}
|
||||
this.lastMouseEvent = this.lastMouseEvent.then(() => new Promise((resolve) => {
|
||||
@@ -1812,7 +1812,7 @@ registry.ImageShapeHoverEffet = publicWidget.Widget.extend({
|
||||
*/
|
||||
_onMouseLeave() {
|
||||
this.lastMouseEvent = this.lastMouseEvent.then(() => new Promise((resolve) => {
|
||||
if (!this.originalImgSrc || !this.svgInEl) {
|
||||
if (!this.originalImgSrc || !this.svgInEl || !this.$target[0].dataset.hoverEffect) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3557,6 +3557,10 @@ options.registry.WebsiteAnimate = options.Class.extend({
|
||||
this._toggleImagesLazyLoading(true);
|
||||
}
|
||||
if (widgetValue === "onHover") {
|
||||
// Pause the history until the hover effect is applied in
|
||||
// "setImgShapeHoverEffect". This prevents saving the intermediate
|
||||
// steps done (in a tricky way) up to that point.
|
||||
this.options.wysiwyg.odooEditor.historyPauseSteps();
|
||||
this.trigger_up("option_update", {
|
||||
optionName: "ImageTools",
|
||||
name: "enable_hover_effect",
|
||||
|
||||
Reference in New Issue
Block a user