ea158e595774ba97924827663b6d19dd4d348257
chmalee
  Tue Jun 24 12:02:22 2025 -0700
Fix bug introduced in last tooltips commit that un-disabled tooltips when right click menu is open, refs #34462

diff --git src/hg/js/utils.js src/hg/js/utils.js
index 6492729e5ea..dca5efc5b28 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -4060,30 +4060,32 @@
 
     // the page is scrolled or otherwise off the screen
     if (topOffset <= 0) {
         topOffset = mouseY - window.scrollY;
     }
 
     if (leftOffset < 0) {
         throw new Error("trying to position off of screen to left");
     }
     popUpEl.style.left = leftOffset + "px";
     popUpEl.style.top = topOffset + "px";
 }
 
 // The div that moves around the users screen with the visible mouseover text
 let  mouseoverContainer;
+// Global needed for contextmenu to disable tooltips
+var suppressTooltips = false;
 
 function addMouseover(ele1, text = null, ele2 = null) {
     /* Adds wrapper elements to control various mouseover events using mouseenter/mouseleave. */
     if (!mouseoverContainer) {
         mouseoverContainer = document.createElement("div");
         mouseoverContainer.className = "tooltip";
         mouseoverContainer.style.position = "fixed";
         mouseoverContainer.style.display = "inline-block";
         mouseoverContainer.style.visibility = "hidden";
         mouseoverContainer.style.opacity = "0";
         mouseoverContainer.id = "mouseoverContainer";
         let tooltipTextSize = localStorage.getItem("tooltipTextSize");
         if (tooltipTextSize === null) {tooltipTextSize = window.browserTextSize;}
         mouseoverContainer.style.fontSize =  tooltipTextSize + "px";
         document.body.append(mouseoverContainer);
@@ -4138,30 +4140,31 @@
             clearTimeout(mouseoverContainer._hideTimeout);
             mouseoverContainer._hideTimeout = null;
         }
     });
     mouseoverContainer.addEventListener("mouseleave", function() {
         mouseoverContainer._isMouseOver = false;
         // Hide after a short delay to allow for quick mouse movements
         mouseoverContainer._hideTimeout = setTimeout(function() {
             hideMouseoverText(mouseoverContainer);
         }, 100);
     });
 }
 
 function showTooltipForElement(ele, ev) {
     // Show the tooltip for the given element
+    if (suppressTooltips) {return;}
     let text = ele.getAttribute("mouseoverText");
     if (!text) return;
     mouseoverContainer.replaceChildren();
     let newEl = document.createElement("span");
     newEl.style = "max-width: 400px";
     newEl.innerHTML = text;
     mouseoverContainer.appendChild(newEl);
     positionMouseover(ev, ele, mouseoverContainer, ev.pageX, ev.pageY);
     mouseoverContainer.classList.add("isShown");
     mouseoverContainer.style.opacity = "1";
     mouseoverContainer.style.visibility = "visible";
     mouseoverContainer.setAttribute("origItemMouseoverId", ele.getAttribute("mouseoverid"));
 }
 
 function hideMouseoverText(ele) {
@@ -4187,47 +4190,39 @@
         if (a.title !== undefined &&
                 (a.title.startsWith("click & drag to scroll") || a.title.startsWith("drag select or click to zoom")))
             a.title = "";
         else if (a.title !== undefined && a.title.length > 0) {
             if (a.title.startsWith("Click to alter the display density")) {
                 // these tooltips have a longer delay:
                 a.setAttribute("tooltipDelay", "delayed");
             }
             titleTagToMouseover(a);
         }
     });
 
     /* Mouseover should clear if you leave the document window altogether */
     document.body.addEventListener("mouseleave", (ev) => {
         hideMouseoverText(mouseoverContainer);
-        // let mouseovers show up again upon moving back in to the window
-        // but only need the event once
-        // use capture: true to force this event to happen
-        // before the regular mouseover event
-        document.body.addEventListener("mouseover", (evt) => {
-        }, {capture: true, once: true});
     });
 
     /* make the mouseovers go away if we are in an input */
     const inps = document.getElementsByTagName("input");
     for (let inp of inps) {
         if (!(inp.type == "hidden" || inp.type == "HIDDEN")) {
             if (inp.type !== "submit") {
                 inp.addEventListener("focus", (ev) => {
                     hideMouseoverText(mouseoverContainer);
-                    inp.addEventListener("blur", (evt) => {
-                    }, {once: true});
                 });
             } else {
                 // the buttons are inputs that don't blur right away (or ever? I can't tell), so
                 // be sure to restore the tooltips when they are clicked
                 inp.addEventListener("click", (ev) => {
                     hideMouseoverText(mouseoverContainer);
                 });
             }
         }
     }
     /* on a select, we can hide the tooltip on focus, but don't disable them
      * altogether, because it's easy to click out of a select without actually
      * losing focus, and we can't detect that because the web browser handles
      * that click separately */
     const sels = document.getElementsByTagName("select");