From 223491036af35b6c535651f7fb8416287c70f64f Mon Sep 17 00:00:00 2001 From: Deepak Shah Date: Wed, 16 Mar 2022 09:21:34 +0000 Subject: [PATCH] [FIX] web_editor: traceback after clicking crop button. Before this commit: After selecting an image and clicking on crop button, crop widget displays and vanish immediately and crop does not work. After clicking on screen, it raises an error (Cannot read properties of null (reading 'removeChild'). After this commit: The crop button works fine without raising any traceback. Task-2804892 X-original-commit: 1ab1c15386f778b04eb78f26b1e0934f3329c6af Part-of: odoo/odoo#90401 --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 0044ef5345f..75ffde1e441 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1299,7 +1299,9 @@ const Wysiwyg = Widget.extend({ if (!this.lastMediaClicked) { return; } - new weWidgets.ImageCropWidget(this, this.lastMediaClicked).appendTo(this.$editable); + new weWidgets.ImageCropWidget(this, this.lastMediaClicked).appendTo(this.odooEditor.document.body); + this.odooEditor.toolbarHide(); + $(this.lastMediaClicked).on('image_cropper_destroyed', () => this.odooEditor.toolbarShow()); }); $toolbar.find('#image-transform').click(e => { if (!this.lastMediaClicked) {