From dfd5eea60b71c5759442936b32a8d8d33093b1ce Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Wed, 14 Dec 2022 13:26:37 +0000 Subject: [PATCH] [FIX] web_editor: fix picking a shape when sibling has the last one Commit [1] introduced the shape system. This system was able to chain shapes depending on the shape of the previous sibling element. Unfortunately, if the shape selected on the sibling was the last shape available, clicking on the toggle shape button would result in nothing happening. This commit fixes that by defaulting to the first shape if no possible shapes are given by the sibling. [1]: https://github.com/odoo/odoo/commit/b84e0af742c51b88b4c108ebec2d0c7fff4b7483 opw-3082292 closes odoo/odoo#108017 X-original-commit: 9bdd8faea9f0126305856a40b3215589e6b3e610 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Arthur Detroux (ard) --- addons/web_editor/static/src/js/editor/snippets.options.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 96e1e3c99b3..f195fff96f2 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -6991,7 +6991,12 @@ registry.BackgroundShape = SnippetOptionWidget.extend({ shapeToSelect = possibleShapes.find((shape, i) => { return possibleShapes[i - 1] === previousShape; }); - } else { + } + // If there is no previous sibling, if the previous sibling had the + // last shape selected or if the previous shape could not be found + // in the possible shapes, default to the first shape. ([0] being no + // shapes selected.) + if (!shapeToSelect) { shapeToSelect = possibleShapes[1]; } this.trigger_up('snippet_edition_request', {exec: () => {