Skip to content

Commit

Permalink
[FIX] web_editor: remove image to save when removing background image
Browse files Browse the repository at this point in the history
Since [1] when options on background images have been applied as soon as
they were modified instead of on save, those options were not reset when
the background was removed.

This commit removes those options when the background image is removed.

Steps to reproduce:
- Drop a Text snippet.
- Add a background image.
- Remove the background image.
- Save.

=> Save failed.

[1]: odoo@4a797f5

task-3794812

closes odoo#158326

X-original-commit: 23c8050
Signed-off-by: Romain Derie (rde) <[email protected]>
Signed-off-by: Benoit Socias (bso) <[email protected]>
Co-authored-by: Serge Bayet <[email protected]>
  • Loading branch information
bso-odoo and SergeBayet committed Mar 21, 2024
1 parent 0b8010a commit 4b2656b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion addons/web_editor/static/src/js/editor/image_processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const modifierFields = [
'originalSrc',
'resizeWidth',
'aspectRatio',
"bgSrc",
"mimetypeBeforeConversion",
];
export const isGif = (mimetype) => mimetype === 'image/gif';

Expand Down Expand Up @@ -598,7 +600,7 @@ export function getDataURLBinarySize(dataURL) {
return dataURL.split(',')[1].length / 4 * 3;
}

export const removeOnImageChangeAttrs = [...cropperDataFields, ...modifierFields, 'aspectRatio'];
export const removeOnImageChangeAttrs = [...cropperDataFields, ...modifierFields];

export default {
applyModifications,
Expand Down
6 changes: 5 additions & 1 deletion addons/web_editor/static/src/js/editor/snippets.options.js
Original file line number Diff line number Diff line change
Expand Up @@ -7973,7 +7973,11 @@ registry.BackgroundImage = SnippetOptionWidget.extend({
this.$target.addClass('oe_img_bg o_bg_img_center');
} else {
delete parts.url;
this.$target.removeClass('oe_img_bg o_bg_img_center');
this.$target[0].classList.remove(
"oe_img_bg",
"o_bg_img_center",
"o_modified_image_to_save",
);
}
const combined = backgroundImagePartsToCss(parts);
this.$target.css('background-image', combined);
Expand Down

0 comments on commit 4b2656b

Please sign in to comment.