diff --git a/packages/sage-system/lib/tooltip.js b/packages/sage-system/lib/tooltip.js index defab8d939..71d3494c82 100644 --- a/packages/sage-system/lib/tooltip.js +++ b/packages/sage-system/lib/tooltip.js @@ -15,10 +15,16 @@ Sage.tooltip = (function() { // TODO: Reverting tooltip reveal on focus/blur until further investigation of persistent focus // can resolve it lingering when it shouldn't. - function init(el) { + function init(el, onClick) { el.addEventListener("mouseenter", buildToolTip); // el.addEventListener("focus", buildToolTip); el.addEventListener("mouseleave", removeTooltip); + el.addEventListener("click", function(ev) { + removeTooltip(ev); + if (onClick) { + onClick(ev); + } + }); // el.addEventListener("blur", removeTooltip); } @@ -50,7 +56,7 @@ Sage.tooltip = (function() { // Removes tooltip from DOM function removeTooltip(evt) { - if (!evt.target.hasAttribute(DATA_ATTR) || !document.querySelector(SELECTOR) || !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}`)); diff --git a/yarn.lock b/yarn.lock index 5fe5379968..06aa29b3b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20489,4 +20489,4 @@ zwitch@^1.0.0: zxcvbn@^4.4.2: version "4.4.2" resolved "https://registry.npmjs.org/zxcvbn/-/zxcvbn-4.4.2.tgz" - integrity sha512-Bq0B+ixT/DMyG8kgX2xWcI5jUvCwqrMxSFam7m0lAf78nf04hv6lNCsyLYdyYTrCVMqNDY/206K7eExYCeSyUQ== + integrity sha512-Bq0B+ixT/DMyG8kgX2xWcI5jUvCwqrMxSFam7m0lAf78nf04hv6lNCsyLYdyYTrCVMqNDY/206K7eExYCeSyUQ== \ No newline at end of file