From 9f93fa8e77b11da2fcf60f606784eec49a94778a Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Thu, 2 Dec 2021 17:28:12 +0000 Subject: [PATCH] [FIX] web_editor, website: fix menu edtion from the "edit menu" button Before this commit, editing a menu item after clicking on the "edit menu" button of the link popover, in edit mode, would not save the change. This was caused by the "Double-click to edit" tooltip that is shown over media and links. Triggering the bootstrap tooltip on a target leads to attribute mutations (data-original-title, title and aria-describedby), that were processed by the EditPageMenu observer to set a view as o_dirty. The website.menu was therefore saved a first time by the edit menu dialog with the correct value, and a second time with the outdated label from the page. To solve that, the observer is deactivated when showing the "Double-click to edit" tooltip over a link or a media, so that the website.menu is updated only once, when saving the edit menu dialog. task-2513588 X-original-commit: 4244b60f36acbdbdc17c24d45144604d1276c15f Part-of: odoo/odoo#81351 --- .../static/src/js/wysiwyg/wysiwyg.js | 2 ++ .../website/static/tests/tours/edit_menus.js | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 0a90e71842d..97ee5c39d42 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1431,7 +1431,9 @@ const Wysiwyg = Widget.extend({ if (!this.showTooltip || $target.attr('title') !== undefined) { return; } + this.odooEditor.observerUnactive(); $target.tooltip({title: _t('Double-click to edit'), trigger: 'manual', container: 'body'}).tooltip('show'); + this.odooEditor.observerActive(); setTimeout(() => $target.tooltip('dispose'), 800); }, 400); } diff --git a/addons/website/static/tests/tours/edit_menus.js b/addons/website/static/tests/tours/edit_menus.js index e26c1236c55..7567cb18a8c 100644 --- a/addons/website/static/tests/tours/edit_menus.js +++ b/addons/website/static/tests/tours/edit_menus.js @@ -84,6 +84,7 @@ tour.register('edit_menus', { clickOnSave, clickOnSave, wTourUtils.clickOnEdit(), + // Edit the new menu item from the "edit link" popover button wTourUtils.clickOnExtraMenuItem({extra_trigger: '#oe_snippets.o_loaded'}), { content: "Menu should have a new link item", @@ -99,9 +100,37 @@ tour.register('edit_menus', { run: 'text Modnar', }, clickOnSave, + ...wTourUtils.clickOnSave(), + // Edit the menu item from the "edit menu" popover button + wTourUtils.clickOnEdit(), + wTourUtils.clickOnExtraMenuItem({extra_trigger: '#oe_snippets.o_loaded'}), { content: "Label should have changed", trigger: '#top_menu .nav-item a:contains("Modnar")', + }, + { + content: "Click on the popover Edit Menu button", + trigger: '.o_edit_menu_popover a.js_edit_menu', + }, + { + content: "Click on the dialog Edit Menu button", + trigger: '.oe_menu_editor .js_menu_label:contains("Modnar")', + run: function () { + const liEl = this.$anchor[0].closest('[data-menu-id]'); + liEl.querySelector('button.js_edit_menu').click(); + }, + }, + { + content: "Change the label", + trigger: '.o_link_dialog #o_link_dialog_label_input', + run: 'text Modnar !!', + }, + clickOnSave, + clickOnSave, + wTourUtils.clickOnExtraMenuItem({extra_trigger: 'a[data-action=edit]'}), + { + content: "Label should have changed", + trigger: '#top_menu .nav-item a:contains("Modnar !!")', run: () => {}, // It's a check. }, ]);