diff --git a/addons/web_tour/static/src/js/tip.js b/addons/web_tour/static/src/js/tip.js index d9446341de7..2e0747e126d 100644 --- a/addons/web_tour/static/src/js/tip.js +++ b/addons/web_tour/static/src/js/tip.js @@ -179,7 +179,7 @@ var Tip = Widget.extend({ this.$el.addClass("o_animated"); }, _bind_anchor_events: function () { - this.consume_event = Tip.getConsumeEventType(this.$anchor); + this.consume_event = Tip.getConsumeEventType(this.$anchor, this.info.run); this.$consumeEventAnchor = this.$anchor; // jQuery-ui draggable triggers 'drag' events on the .ui-draggable element, // but the tip is attached to the .ui-draggable-handle element which may @@ -189,6 +189,11 @@ var Tip = Widget.extend({ } else if (this.consume_event.includes('apply.daterangepicker')) { this.$consumeEventAnchor = this.$anchor.parent().children('.o_field_date_range'); } + // when an element is dragged inside a sortable container (with classname + // 'ui-sortable'), jQuery triggers the 'sort' event on the container + if (this.consume_event === "sort") { + this.$consumeEventAnchor = this.$anchor.closest('.ui-sortable'); + } this.$consumeEventAnchor.on(this.consume_event + ".anchor", (function (e) { if (e.type !== "mousedown" || e.which === 1) { // only left click this.trigger("tip_consumed"); @@ -309,7 +314,12 @@ var Tip = Widget.extend({ }, }); -Tip.getConsumeEventType = function ($element) { +/** + * @static + * @param {jQuery} $element + * @param {string} [run] the run parameter of the tip (only strings are useful) + */ +Tip.getConsumeEventType = function ($element, run) { if ($element.hasClass('o_field_many2one') || $element.hasClass('o_field_many2manytags')) { return 'autocompleteselect'; } else if ($element.is("textarea") || $element.filter("input").is(function () { @@ -327,6 +337,13 @@ Tip.getConsumeEventType = function ($element) { return "input"; } else if ($element.hasClass('ui-draggable-handle')) { return "drag"; + } else if (typeof run === 'string' && run.indexOf('drag_and_drop') === 0) { + // this is a heuristic: the element has to be dragged and dropped but it + // doesn't have class 'ui-draggable-handle', so we check if it has an + // ui-sortable parent, and if so, we conclude that its event type is 'sort' + if ($element.closest('.ui-sortable')) { + return 'sort'; + } } return "click"; };