[FIX] web_editor: prevents enabling options that are not visible
This commit prevents the activation of options when no option section is visible, and disables overlay if there are no options to enable. Steps to reproduce the bug: - Go to website edit mode (homepage). - Click on the white area (the <main> element) below the "drag building blocks here" block. - Bug: The customize tab is activated in the editor panel, even though there are no options. task-3199281 closes odoo/odoo#118461 X-original-commit: af49b1aba1454f80663c4e88e8c4915eb75bd0ff Signed-off-by: loco-odoo <loco@odoo.com>
This commit is contained in:
@@ -659,6 +659,15 @@ var SnippetEditor = Widget.extend({
|
||||
await Promise.all(editorUIsToUpdate.map(editor => editor.updateOptionsUI()));
|
||||
await Promise.all(editorUIsToUpdate.map(editor => editor.updateOptionsUIVisibility()));
|
||||
|
||||
// As the 'd-none' class is added to option sections that have no visible
|
||||
// options with 'updateOptionsUIVisibility', if no option section is
|
||||
// visible, we prevent the activation of the options.
|
||||
const optionsSectionVisible = editorUIsToUpdate.some(
|
||||
editor => !editor.$optionsSection[0].classList.contains('d-none')
|
||||
);
|
||||
if (editorUIsToUpdate.length > 0 && !optionsSectionVisible) {
|
||||
return null;
|
||||
}
|
||||
return this._customize$Elements;
|
||||
},
|
||||
/**
|
||||
@@ -2577,6 +2586,14 @@ var SnippetsMenu = Widget.extend({
|
||||
}
|
||||
|
||||
if (!previewMode) {
|
||||
// As some options can only be generated using JavaScript
|
||||
// (e.g. 'SwitchableViews'), it may happen at this point
|
||||
// that the overlay is activated even though there are no
|
||||
// options. That's why we disable the overlay if there are
|
||||
// no options to enable.
|
||||
if (editorToEnable && !customize$Elements) {
|
||||
editorToEnable.toggleOverlay(false);
|
||||
}
|
||||
this._updateRightPanelContent({
|
||||
content: customize$Elements || [],
|
||||
tab: customize$Elements ? this.tabs.OPTIONS : this.tabs.BLOCKS,
|
||||
|
||||
Reference in New Issue
Block a user