From fccac358dae7092c8c7cd90ba1ee89c712bc86e9 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Thu, 23 Feb 2023 08:47:46 +0000 Subject: [PATCH] [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
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 --- .../static/src/js/editor/snippets.editor.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 8975b053139..a7ee7bb6cc1 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -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,