[FIX] web_editor: unblock the editor after dropping the "Quotes" snippet
Before this commit, when the user dropped the "Quotes" snippet, the editor was not allowing to drop any more snippet (see [1]). This was because the editors initialization related to the drop of the "Quotes" snippet was not able to be fully performed. Indeed, it is composed of carousel items, themself containing images. As some of those carousel items are hidden, the images they contains are too... and some options actually wait to access their naturalWidth. As the images are lazy loaded since [2], we were thus waiting infinitely. [1]: https://github.com/odoo/odoo/commit/277f39904e7218bef2dd23b1c5b719ce8660008f [2]: https://github.com/odoo/odoo/commit/617c716aeafd7bbc776d81da134a9b25329f08c9 closes odoo/odoo#61308 X-original-commit: 2e37befbf84f0f587774d4c2fa095487148b549b Signed-off-by: Samuel Degueldre <sdegueldre@users.noreply.github.com>
This commit is contained in:
@@ -3200,15 +3200,6 @@ const ImageHandlerOption = SnippetOptionWidget.extend({
|
||||
async willStart() {
|
||||
const _super = this._super.bind(this);
|
||||
await this._loadImageInfo();
|
||||
// Make sure image is loaded because we need its naturalWidth to render XML
|
||||
const img = this._getImg();
|
||||
await new Promise((resolve, reject) => {
|
||||
if (img.complete) {
|
||||
return resolve();
|
||||
}
|
||||
img.addEventListener('load', resolve, {once: true});
|
||||
img.addEventListener('error', resolve, {once: true});
|
||||
});
|
||||
return _super(...arguments);
|
||||
},
|
||||
|
||||
@@ -3275,8 +3266,19 @@ const ImageHandlerOption = SnippetOptionWidget.extend({
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_computeWidgetState(methodName, params) {
|
||||
async _computeWidgetState(methodName, params) {
|
||||
const img = this._getImg();
|
||||
|
||||
// Make sure image is loaded because we need its naturalWidth
|
||||
await new Promise((resolve, reject) => {
|
||||
if (img.complete) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
img.addEventListener('load', resolve, {once: true});
|
||||
img.addEventListener('error', resolve, {once: true});
|
||||
});
|
||||
|
||||
switch (methodName) {
|
||||
case 'selectWidth':
|
||||
return img.naturalWidth;
|
||||
|
||||
Reference in New Issue
Block a user