Skip to content

Commit

Permalink
Merge pull request #1870 from Kajabi/fix/sentry-error-tooltip
Browse files Browse the repository at this point in the history
Sentry error - ensure valid node before removal to prevent errors
  • Loading branch information
monicawheeler authored Mar 12, 2024
2 parents 152d794 + fd4b3f8 commit 0f23c37
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/sage-system/lib/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,18 @@ Sage.tooltip = (function() {
positionTooltip(evt.target, tooltip, pos);
}


// Removes tooltip from DOM
function removeTooltip(evt) {
if (!evt.target.hasAttribute(DATA_ATTR) || !document.querySelector(SELECTOR) || !document.querySelector(`.${TOOLTIP_CLASS}`) || !evt.target.dataset.jsTooltip) return;
if (!evt.target.hasAttribute(DATA_ATTR) || !document.querySelector(SELECTOR) || !document.querySelector(`.${TOOLTIP_CLASS}`) || !evt.target.dataset.jsTooltip) return;

window.requestAnimationFrame(function() {
document.body.removeChild(document.querySelector(`.${TOOLTIP_CLASS}`));
var tooltip = document.querySelector(`.${TOOLTIP_CLASS}`);
if (tooltip && tooltip.parentNode === document.body) { // Ensure tooltip exists and its parent is document.body before removing
document.body.removeChild(tooltip);
}
});
}


// Builds list of modifier classes from array of data-attributes
function generateClasses(ele, evt) {
ele.dataItems.forEach(function(item) {
Expand Down

0 comments on commit 0f23c37

Please sign in to comment.