Fix stuck tooltips bug
This commit is contained in:
parent
b546dd4033
commit
537a310f4c
@ -843,41 +843,23 @@ define([
|
|||||||
// This is the robust solution to remove dangling tooltips
|
// This is the robust solution to remove dangling tooltips
|
||||||
// The mutation observer does not always find removed nodes.
|
// The mutation observer does not always find removed nodes.
|
||||||
//setInterval(UI.clearTooltips, delay);
|
//setInterval(UI.clearTooltips, delay);
|
||||||
var checkRemoved = function (x) {
|
|
||||||
var out = false;
|
|
||||||
var xId = $(x).attr('aria-describedby');
|
|
||||||
if (xId) {
|
|
||||||
if (xId.indexOf('tippy-') === 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$(x).find('[aria-describedby]').each(function (i, el) {
|
|
||||||
var id = el.getAttribute('aria-describedby');
|
|
||||||
if (id.indexOf('tippy-') !== 0) { return; }
|
|
||||||
out = true;
|
|
||||||
});
|
|
||||||
return out;
|
|
||||||
};
|
|
||||||
$('[title]').each(addTippy);
|
$('[title]').each(addTippy);
|
||||||
var observer = new MutationObserver(function(mutations) {
|
var observer = new MutationObserver(function(mutations) {
|
||||||
var removed = false;
|
|
||||||
mutations.forEach(function(mutation) {
|
mutations.forEach(function(mutation) {
|
||||||
if (mutation.type === "childList") {
|
if (mutation.type === "childList") {
|
||||||
for (var i = 0; i < mutation.addedNodes.length; i++) {
|
for (var i = 0; i < mutation.addedNodes.length; i++) {
|
||||||
if ($(mutation.addedNodes[i]).attr('title')) {
|
|
||||||
addTippy(0, mutation.addedNodes[i]);
|
|
||||||
}
|
|
||||||
$(mutation.addedNodes[i]).find('[title]').each(addTippy);
|
$(mutation.addedNodes[i]).find('[title]').each(addTippy);
|
||||||
}
|
}
|
||||||
for (var j = 0; j < mutation.removedNodes.length; j++) {
|
|
||||||
removed |= checkRemoved(mutation.removedNodes[j]);
|
if (mutation.removedNodes.length !== 0) {
|
||||||
|
UI.clearTooltips();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mutation.type === "attributes" && mutation.attributeName === "title") {
|
if (mutation.type === "attributes" && mutation.attributeName === "title") {
|
||||||
addTippy(0, mutation.target);
|
addTippy(0, mutation.target);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (removed) { UI.clearTooltips(); }
|
|
||||||
});
|
});
|
||||||
observer.observe($('body')[0], {
|
observer.observe($('body')[0], {
|
||||||
attributes: true,
|
attributes: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user