[FIX] web_editor,website_sale: fix click on pricelist while editing
Prior to this commit, when a user edits the Shop page, clicks on the pricelist dropdown and finally clicks elsewhere, a traceback occurs: `Uncaught TypeError: Cannot read properties of undefined (reading 'getColorNames')` This commit ensures the link tools is not toggles on dropdown links, i.e. the customizable links selector does not contain the dropdown anymore. task-2695091 closes odoo/odoo#87300 X-original-commit: 73b98a53e8bd19b3b96502d6006b002819287e44 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Signed-off-by: Thibault Libioulle (tle) <tle@odoo.com>
This commit is contained in:
@@ -74,7 +74,11 @@ 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"])';
|
||||
this.customizableLinksSelector = 'a'
|
||||
+ ':not([data-toggle="tab"])'
|
||||
+ ':not([data-toggle="collapse"])'
|
||||
+ ':not([data-toggle="dropdown"])'
|
||||
+ ':not(.dropdown-item)';
|
||||
// navigator.onLine is sometimes a false positive, this._isOnline use
|
||||
// more heuristics to bypass the limitation.
|
||||
this._isOnline = true;
|
||||
@@ -285,7 +289,8 @@ const Wysiwyg = Widget.extend({
|
||||
&& $target[0].isContentEditable
|
||||
&& !$target.attr('data-oe-model')
|
||||
&& !$target.find('> [data-oe-model]').length
|
||||
&& !$target[0].closest('.o_extra_menu_items')) {
|
||||
&& !$target[0].closest('.o_extra_menu_items')
|
||||
&& $target[0].isContentEditable) {
|
||||
this.linkPopover = $target.data('popover-widget-initialized');
|
||||
if (!this.linkPopover) {
|
||||
// TODO this code is ugly maybe the mutex should be in the
|
||||
@@ -1021,7 +1026,7 @@ const Wysiwyg = Widget.extend({
|
||||
*/
|
||||
toggleLinkTools(options = {}) {
|
||||
const linkEl = getInSelection(this.odooEditor.document, 'a');
|
||||
if (linkEl && !linkEl.matches(this.customizableLinksSelector)) {
|
||||
if (linkEl && (!linkEl.matches(this.customizableLinksSelector) || !linkEl.isContentEditable)) {
|
||||
return;
|
||||
}
|
||||
if (this.snippetsMenu && !options.forceDialog) {
|
||||
@@ -1582,7 +1587,7 @@ const Wysiwyg = Widget.extend({
|
||||
this._updateFaResizeButtons();
|
||||
}
|
||||
const link = getInSelection(this.odooEditor.document, this.customizableLinksSelector);
|
||||
if (isInMedia || link) {
|
||||
if (isInMedia || (link && link.isContentEditable)) {
|
||||
// Handle the media/link's tooltip.
|
||||
this.showTooltip = true;
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import tour from 'web_tour.tour';
|
||||
|
||||
tour.register('shop_editor', {
|
||||
test: true,
|
||||
url: '/shop?enable_editor=1',
|
||||
}, [{
|
||||
content: "Click on pricelist dropdown",
|
||||
trigger: "div.o_pricelist_dropdown a[data-toggle=dropdown]",
|
||||
}, {
|
||||
trigger: "input[name=search]",
|
||||
extra_trigger: "div.o_pricelist_dropdown a[data-toggle=dropdown][aria-expanded=true]",
|
||||
content: "Click somewhere else in the shop.",
|
||||
}, {
|
||||
trigger: "div.o_pricelist_dropdown a[data-toggle=dropdown]",
|
||||
extra_trigger: "div.o_pricelist_dropdown a[data-toggle=dropdown][aria-expanded=false]",
|
||||
content: "Click on the pricelist again.",
|
||||
}]);
|
||||
@@ -311,3 +311,6 @@ class TestUi(HttpCaseWithUserDemo, HttpCaseWithUserPortal):
|
||||
config.execute()
|
||||
|
||||
self.start_tour("/", 'shop_list_view_b2c', login="admin")
|
||||
|
||||
def test_07_editor_shop(self):
|
||||
self.start_tour("/", 'shop_editor', login="admin")
|
||||
|
||||
Reference in New Issue
Block a user