3977a0035febcc3af4ef51f12fd75548a7cc7062
tdreszer
  Wed Dec 14 16:44:17 2011 -0800
Minor cleanup to hui.c  Fix edge case bug in hgTracks.js where right click is lost.
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 0546cef..c5f5742 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -1550,31 +1550,30 @@
     {   // Find mapItem for given event; returns item object or null if none found.
 
         if(rightClick.currentMapItem) {
             return rightClick.currentMapItem;
         }
 
         // rightClick for non-map items that can be resolved to their parent tr and then trackName (e.g. items in gray bar)
         var tr = $( e.target ).parents('tr.imgOrd');
         if ( $(tr).length == 1 ) {
             var a = /tr_(.*)/.exec($(tr).attr('id'));  // voodoo
             if(a && a[1]) {
                 var id = a[1];
                 return rightClick.makeMapItem(id);
             }
         }
-        warn("ASSERT: findMapItem failed.");// Should not ever get to this point
         return null;
     },
 
     windowOpenFailedMsg: function ()
     {
         warn("Your web browser prevented us from opening a new window.\n\nPlease change your browser settings to allow pop-up windows from " + document.domain + ".");
     },
 
     handleZoomCodon: function (response, status)
     {
         var json = eval("(" + response + ")");
         if(json.pos) {
             genomePos.set(json.pos, 3);
             if(document.TrackForm)
                 document.TrackForm.submit();
@@ -1935,30 +1934,32 @@
 
     makeImgTag: function (img)
     {   // Return img tag with explicit dimensions for img (dimensions are currently hardwired).
         // This fixes the "weird shadow problem when first loading the right-click menu" seen in FireFox 3.X,
         // which occurred b/c FF doesn't actually fetch the image until the menu is being shown.
         return "<img style='width:16px; height:16px; border-style:none;' src='../images/" +
                 img + "' />";
     },
 
 
     load: function (img)
     {
         rightClick.menu = img.contextMenu(
             function() {
                 popUp.cleanup();   // Popup box is not getting closed properly so must do it here
+                if (rightClick.selectedMenuItem == null)  // This is literally an edge case so ignore
+                    return;
 
                 var menu = [];
                 var selectedImg = rightClick.makeImgTag("greenChecksm.png");
                 var blankImg    = rightClick.makeImgTag("invisible16.png");
                 var done = false;
                 if(rightClick.selectedMenuItem && rightClick.selectedMenuItem.id != null) {
                     var href = rightClick.selectedMenuItem.href;
                     var isHgc, isGene;
                     if(href) {
                         isGene = href.match("hgGene");
                         isHgc = href.match("hgc");
                     }
                     var id = rightClick.selectedMenuItem.id;
                     var rec = hgTracks.trackDb[id];
                     var offerHideSubset    = false;