[FIX] web_editor: fix editor-lock after gallery image reordering again
The bug was already solved with [1] but was reintroduced later for another reason. [1] solved the problem by checking that the current option is not destroyed before asking for an UI update thanks to a trigger_up (the option was destroyed because of image reordering). The bug is now reintroduced for the same basic reason: a new trigger_up was added between the potential option destroy and the destroy check, so if the option is destroyed, that trigger_up fails to be triggered and the editor is locked. This commit solves the problem once and for all, hopefully, with a more robust solution: only destroy options when none is being processed. That way we ensure that all trigger_up occuring during an option activation / update can be properly done. [1]: https://github.com/odoo/odoo/commit/9eeea4c4107dc15984c475582d5ee58a17cd2568 X-original-commit: 7770430f78ee9e122a732fa042226d362467158e
This commit is contained in:
@@ -1094,12 +1094,15 @@ var SnippetsMenu = Widget.extend({
|
||||
* Updates the cover dimensions of the current snippet editor.
|
||||
*/
|
||||
updateCurrentSnippetEditorOverlay: function () {
|
||||
this.snippetEditors = _.filter(this.snippetEditors, function (snippetEditor) {
|
||||
this.snippetEditors = this.snippetEditors.filter(snippetEditor => {
|
||||
if (snippetEditor.$target.closest('body').length) {
|
||||
snippetEditor.cover();
|
||||
return true;
|
||||
}
|
||||
snippetEditor.destroy();
|
||||
// Destroy options whose $target are not in the DOM anymore but
|
||||
// only do it once all options executions are done.
|
||||
this._mutex.exec(() => snippetEditor.destroy());
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -2493,13 +2493,6 @@ const SnippetOptionWidget = Widget.extend({
|
||||
// Call widget option methods and update $target
|
||||
await this._select(previewMode, widget);
|
||||
|
||||
// Enabling an option and notifying that the $target has changed
|
||||
// may destroy the option (if the DOM is altered in such a way the
|
||||
// option is not attached to it anymore). In that case, we must not
|
||||
// wait for a response to the option update.
|
||||
if (this.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
await new Promise(resolve => setTimeout(() => {
|
||||
// Will update the UI of the correct widgets for all options
|
||||
// related to the same $target/editor if necessary
|
||||
|
||||
Reference in New Issue
Block a user