From 62eea00a9bd004639ed4d6f565d5922668a7ebf4 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Wed, 19 Apr 2023 14:26:08 +0000 Subject: [PATCH] [FIX] website: prevent dropping generated ToC outside its snippet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the table of content snippet, both its generated entries and its content wrapper can be dropped outside of it. This cannot be allowed because the entries are generated from the wrapped content that belongs to the same table of content snippet. If any of them is missing, the feature is broken. This commit prevents this by hiding the drag handle from the generated table of content and from the content wrapper. Note that they can still be moved using the arrows. task-2752391 closes odoo/odoo#107510 Signed-off-by: Bojabza Soukéina (sobo) --- .../static/src/js/editor/snippets.options.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 5b5aae887a3..1c105cdd16a 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -3633,7 +3633,26 @@ options.registry.sizing.include({ $body.on('mouseup', documentMouseUp); }); return defs; - } + }, + + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + /** + * @override + */ + async updateUIVisibility() { + await this._super(...arguments); + const nonDraggableClasses = [ + 's_table_of_content_navbar_wrap', + 's_table_of_content_main', + ]; + if (nonDraggableClasses.some(c => this.$target[0].classList.contains(c))) { + const moveHandleEl = this.$overlay[0].querySelector('.o_move_handle'); + moveHandleEl.classList.add('d-none'); + } + }, }); options.registry.SwitchableViews = options.Class.extend({