From fe44184b48fded1d4a8ef25553cea3e523819baa Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Tue, 19 Jan 2021 08:26:00 +0000 Subject: [PATCH] [IMP] web_editor: open shape selection when enabling shapes Before this commit when toggling shapes on a snippet background, the shape selection dropdown was shown as closed. After this commit when toggling shapes on a snippet background, the shape selection dropdown is automatically opened. We have to use a click() on the toggler instead of an open() on the dropdown to make the page containing the selected shape appear when opening. task-2431445 https://github.com/odoo/odoo/pull/64515 --- .../static/src/js/editor/snippets.options.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 65804138a7e..0dad1de1c02 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -934,6 +934,14 @@ const SelectUserValueWidget = BaseSelectionUserValueWidget.extend({ this.menuTogglerEl.appendChild(this.menuTogglerItemEl); } }, + /** + * @override + */ + enable() { + if (!this.menuTogglerEl.classList.contains('active')) { + this.menuTogglerEl.click(); + } + }, //-------------------------------------------------------------------------- // Handlers @@ -4482,6 +4490,10 @@ registry.BackgroundShape = SnippetOptionWidget.extend({ } else { shapeToSelect = possibleShapes[1]; } + this.trigger_up('snippet_edition_request', {exec: () => { + // options for shape will only be available after _toggleShape() returned + this._requestUserValueWidgets('bg_shape_opt')[0].enable(); + }}); return this._handlePreviewState(false, () => ({shape: shapeToSelect})); } },