From 7a698d092e58144b1982baac9b743980107952c8 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Fri, 11 Aug 2017 17:28:23 +0200 Subject: [PATCH] When Cryptpad.clearTooltips() gets called, don't clear tooltips unless their associated element has gone missing so it won't clear a tip someone is trying to read. --- www/common/common-interface.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 83389b816..ded41321c 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -301,7 +301,15 @@ define([ // Tooltips UI.clearTooltips = function () { - $('.tippy-popper').remove(); + // If an element is removed from the UI while a tooltip is applied on that element, the tooltip will get hung + // forever, this is a solution which just searches for tooltips which have no corrisponding element and removes + // them. + var win = $('#pad-iframe')[0].contentWindow; + $('.tippy-popper').each(function (i, el) { + if (win.$('[aria-describedby=' + el.getAttribute('id') + ']').length === 0) { + el.remove(); + } + }); }; UI.addTooltips = function () {