From f534d20674c19ba0cde9d14f057b6e678b78b210 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Tue, 12 Oct 2021 08:38:05 +0000 Subject: [PATCH] [FIX] web_editor, *: fix active class disappearing on tabs snippet * = website Before this commit, the active class of the tabs snippet buttons disappeared when leaving the edition of the buttons. After this commit, it is no longer possible to enable link options for the buttons of the tabs snippet and accordion snippet. Being able to customize these buttons introduces too many bugs and is not really necessary. task-2656662 closes odoo/odoo#79190 X-original-commit: 7f33cdcd14ef753cc5bf823bfc1de0d2431e285a Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 9 +++++++-- addons/website/static/src/js/editor/wysiwyg.js | 2 +- addons/website/views/snippets/s_tabs.xml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index b3ac532fa49..08246164068 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -55,6 +55,7 @@ const Wysiwyg = Widget.extend({ this.colorpickers = {}; this._onDocumentMousedown = this._onDocumentMousedown.bind(this); this._onBlur = this._onBlur.bind(this); + this.customizableLinksSelector = 'a:not([data-toggle="tab"]):not([data-toggle="collapse"])'; }, /** * @@ -185,7 +186,7 @@ const Wysiwyg = Widget.extend({ self.openMediaDialog(params); }); - this.$editable.on('dblclick', 'a', function (ev) { + this.$editable.on('dblclick', this.customizableLinksSelector, function (ev) { if (!this.getAttribute('data-oe-model') && self.toolbar.$el.is(':visible')) { self.showTooltip = false; self.toggleLinkTools({ @@ -827,6 +828,10 @@ const Wysiwyg = Widget.extend({ * @param {boolean} [options.noFocusUrl=false] Disable the automatic focusing of the URL field. */ toggleLinkTools(options = {}) { + const linkEl = getInSelection(this.odooEditor.document, 'a'); + if (linkEl && !linkEl.matches(this.customizableLinksSelector)) { + return; + } if (this.snippetsMenu && !options.forceDialog) { if (this.linkTools) { this.linkTools.destroy(); @@ -1344,7 +1349,7 @@ const Wysiwyg = Widget.extend({ this._updateMediaJustifyButton(); this._updateFaResizeButtons(); } - const link = getInSelection(this.odooEditor.document, 'a'); + const link = getInSelection(this.odooEditor.document, this.customizableLinksSelector); if (isInMedia || link) { // Handle the media/link's tooltip. this.showTooltip = true; diff --git a/addons/website/static/src/js/editor/wysiwyg.js b/addons/website/static/src/js/editor/wysiwyg.js index 22ed061b19b..fc7e1b124b5 100644 --- a/addons/website/static/src/js/editor/wysiwyg.js +++ b/addons/website/static/src/js/editor/wysiwyg.js @@ -59,7 +59,7 @@ Wysiwyg.include({ ev.preventDefault(); } - if ($target.is('a') && !$target.attr('data-oe-model') && !$target.find('> [data-oe-model]').length && $target.closest('#wrapwrap').length) { + if ($target.is(this.customizableLinksSelector) && !$target.attr('data-oe-model') && !$target.find('> [data-oe-model]').length && $target.closest('#wrapwrap').length) { if (!$target.data('popover-widget-initialized')) { // TODO this code is ugly maybe the mutex should be in the // editor root widget / the popover should not depend on diff --git a/addons/website/views/snippets/s_tabs.xml b/addons/website/views/snippets/s_tabs.xml index 2e8be00bfbc..edaf4b4ad04 100644 --- a/addons/website/views/snippets/s_tabs.xml +++ b/addons/website/views/snippets/s_tabs.xml @@ -5,7 +5,7 @@
-