Skip to content
Snippets Groups Projects
Commit 67044d64 authored by mgh-odoo's avatar mgh-odoo Committed by Aaron Bohy
Browse files

[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: default avatarAaron Bohy (aab) <aab@odoo.com>
Co-authored-by: default avatarAaron Bohy <aab@odoo.com>
Co-authored-by: default avatarPriyanka Kakadiya <pka@odoo.com>
parent 441c8b0e
No related branches found
No related tags found
No related merge requests found
......@@ -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";
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment