[FIX]tooltip: fix various display problems with the tooltip
[odoo/odoo.git] / addons / web / static / src / js / core.js
index 29f6c3e..23645e2 100644 (file)
@@ -773,15 +773,18 @@ instance.web.unblockUI = function() {
 $.fn.tooltip.Constructor.DEFAULTS.placement = 'auto top';
 $.fn.tooltip.Constructor.DEFAULTS.html = true;
 $.fn.tooltip.Constructor.DEFAULTS.container = 'body';
-//overwrite bootstrap tooltip method to fix bug when using placement
-//auto and the parent element does not exist anymore resulting in
-//an error. This should be remove once bootstrap fix the bug
+//overwrite bootstrap tooltip method to prevent showing 2 tooltip at the same time
 var bootstrap_show_function = $.fn.tooltip.Constructor.prototype.show;
-$.fn.tooltip.Constructor.prototype.show = function (e) {
-    if (this.$element.parent().length === 0){
-        return;
-    }
-    return bootstrap_show_function.call(this, e);
+$.fn.tooltip.Constructor.prototype.show = function () {
+    $('.tooltip').remove();
+    //the following fix the bug when using placement
+    //auto and the parent element does not exist anymore resulting in
+    //an error. This should be remove once we updade bootstrap to a version that fix the bug
+    //edit: bug has been fixed here : https://github.com/twbs/bootstrap/pull/13752
+    var e = $.Event('show.bs.' + this.type);
+    var inDom = $.contains(document.documentElement, this.$element[0]);
+    if (e.isDefaultPrevented() || !inDom) return;
+    return bootstrap_show_function.call(this);
 };
 
 /**