[IMP] web_editor: hide SnippetEditor when no options are shown
Commit [1] moved the switchable views inside a SnippetOption. The implementation of that ended up creating empty page options SnippetEditors displayed on every page. This commit makes sure that if a SnippetEditor doesn't have any options, it is not displayed. [1]: https://github.com/odoo/odoo/commit/69af7dcfeb3ff95c40b00ef0cc7c5c0e4021f9d2 task-2687506 X-original-commit: 39d073ccafddf4b3fbe9ec9f5f11849d77c9bdaa Part-of: odoo/odoo#101687
This commit is contained in:
committed by
qsm-odoo
parent
92fae623d4
commit
ebd73104e6
@@ -705,7 +705,13 @@ var SnippetEditor = Widget.extend({
|
||||
const proms = Object.values(this.styles).map(opt => {
|
||||
return opt.updateUIVisibility();
|
||||
});
|
||||
return Promise.all(proms);
|
||||
await Promise.all(proms);
|
||||
// Hide the snippetEditor if none of its options are visible
|
||||
// This cannot be done using the visibility of the options' UI
|
||||
// because some options can be located in the overlay.
|
||||
const $visibleOptions = this.$optionsSection.find('we-top-button-group, we-customizeblock-option')
|
||||
.children(':not(.d-none)');
|
||||
this.$optionsSection.toggleClass('d-none', !$visibleOptions.length);
|
||||
},
|
||||
/**
|
||||
* Clones the current snippet.
|
||||
|
||||
@@ -5133,17 +5133,6 @@ registry.SnippetMove = SnippetOptionWidget.extend({
|
||||
|
||||
return this._super(...arguments);
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
onFocus: function () {
|
||||
// TODO improve this: hack to hide options section if snippet move is
|
||||
// the only one.
|
||||
const $allOptions = this.$el.parent();
|
||||
if ($allOptions.find('we-customizeblock-option').length <= 1) {
|
||||
$allOptions.addClass('d-none');
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Options
|
||||
|
||||
Reference in New Issue
Block a user