diff options
| author | xO-Tx <mou@odoo.com> | 2021-03-02 14:04:20 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2021-03-05 09:55:32 +0000 |
| commit | 1d483ab5e2f9bba0fd86c6fe4595a9959b2f125d (patch) | |
| tree | 1b57540ce8232f20b9e8e198ce356ec1674d629d /addons/web_editor/static/src/js/editor | |
| parent | 19ef4f1b318b979bf2c6e89ad9962a50e6684dc9 (diff) | |
[FIX] web_editor: fix parent element selection
When a block is removed, the parent will be activated.
If the parent element is empty and removable:
1) It will be removed too.
2) In '_activateSnippet' method, we look for the right element to
be selected using the block's parent (removed from the DOM...).
The goal of this commit is to fix this behaviour by computing the
selected element before parent removal.
task-2431506
closes odoo/odoo#65428
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/js/editor')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.editor.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 57721dd1e87..c759cd84ece 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1477,18 +1477,20 @@ var SnippetsMenu = Widget.extend({ if ($snippet && !$snippet.is(':visible')) { return; } + // Take the first parent of the provided DOM (or itself) which + // should have an associated snippet editor. + // It is important to do that before the mutex exec call to compute it + // before potential ancestor removal. + if ($snippet && $snippet.length) { + $snippet = globalSelector.closest($snippet); + } const exec = previewMode ? action => this._mutex.exec(action) : action => this._execWithLoadingEffect(action, false); return exec(() => { return new Promise(resolve => { - // Take the first parent of the provided DOM (or itself) which - // should have an associated snippet editor and create + enable it. if ($snippet && $snippet.length) { - $snippet = globalSelector.closest($snippet); - if ($snippet.length) { - return this._createSnippetEditor($snippet).then(resolve); - } + return this._createSnippetEditor($snippet).then(resolve); } resolve(null); }).then(editorToEnable => { |
