From 67044d64cdee723515c14ebc62575644d7c37b47 Mon Sep 17 00:00:00 2001 From: mgh-odoo Date: Tue, 19 Nov 2019 11:28:33 +0000 Subject: [PATCH] [FIX] web_tour: consume tip with drag and drop After the rainbowMan issue was fixed here: e5bc2e7, steps were consumed on 'click' events. This caused an issue with the drag and drop event (which breaks tour, because it is expecting a click event). If the user dragged an element, thetip was not getting consumed as no click event was triggered. closes odoo/odoo#40819 X-original-commit: 3f458fe06e6a629edc72428eab749068c2eba1ba Signed-off-by: Aaron Bohy (aab) Co-authored-by: Aaron Bohy Co-authored-by: Priyanka Kakadiya --- addons/web_tour/static/src/js/tip.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/web_tour/static/src/js/tip.js b/addons/web_tour/static/src/js/tip.js index 5bd64ce1c49..e299df9b538 100644 --- a/addons/web_tour/static/src/js/tip.js +++ b/addons/web_tour/static/src/js/tip.js @@ -178,7 +178,14 @@ var Tip = Widget.extend({ }, _bind_anchor_events: function () { this.consume_event = Tip.getConsumeEventType(this.$anchor); - this.$anchor.on(this.consume_event + ".anchor", (function (e) { + 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 + // be one of its children (or the element itself) + if (this.consume_event === "drag") { + this.$consumeEventAnchor = this.$anchor.closest('.ui-draggable'); + } + this.$consumeEventAnchor.on(this.consume_event + ".anchor", (function (e) { if (e.type !== "mousedown" || e.which === 1) { // only left click this.trigger("tip_consumed"); this._unbind_anchor_events(); @@ -189,6 +196,7 @@ var Tip = Widget.extend({ }, _unbind_anchor_events: function () { this.$anchor.off(".anchor"); + this.$consumeEventAnchor.off(".anchor"); }, _get_spaced_inverted_position: function (position) { if (position === "right") return "left+" + this.info.space; @@ -305,6 +313,8 @@ Tip.getConsumeEventType = function ($element) { return !type || !!type.match(/^(email|number|password|search|tel|text|url)$/); })) { return "input"; + } else if ($element.hasClass('ui-draggable-handle')) { + return "drag"; } return "click"; };