From 88d8a2ca8e417c90c7a0eb005fd063599efbc2f4 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 29 Aug 2016 16:15:11 +0200 Subject: [PATCH] [FIX] web_editor: hide header in customize dropdown when it has no content In some snippets, the parent hierarchy has many elements. So, when selecting a deep child of one of those, the customize dropdown had many dropdown headers showing the parent hierarchy but without any option for many of them. Commit de0d9fd6661691488fcf4fd546d89042c0c99a4b already fixed the case where the dropdown only contains dropdown headers. This commit is an adaptation to hide these headers one by one. --- addons/web_editor/static/src/js/snippets.editor.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index bfaeec3975a..020c93cdc17 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -1122,22 +1122,29 @@ data.Editor = Class.extend({ if ($el.data("editor") !== this) { styles = _.filter(styles, function (option) { return !option.preventChildPropagation; }); } + + var count = 0; _.each(_.sortBy(styles, "__order").reverse(), function (style) { - do_action(style, $el); + if (do_action(style, $el)) { + count++; + } }); + $el.toggleClass("hidden", count === 0); }).bind(this)); // Activate the overlay - $style_button.toggleClass("hidden", $ul.children(":not(.dropdown-header):not(.divider):not(.hidden)").length === 0); + $style_button.toggleClass("hidden", $ul.children(":not(.divider):not(.hidden)").length === 0); this.$overlay.toggleClass("oe_active", !!focus); function _do_action_focus(style, $dest) { style.$el.insertAfter($dest); style.on_focus(); + return (style.$el.length > 0); } function _do_action_blur(style, $dest) { style.$el.detach(); style.on_blur(); + return false; } }, });