58572f970097a2a8d39b57e81ccc3700c1f30527
chmalee
  Wed Feb 19 11:35:03 2025 -0800
Fix unintentional call to dragReorder when clicking on a grey bar, fixes #34750

diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 4d2ff7bd56c..eb6fa6ec4dc 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -5784,31 +5784,37 @@
 
                     // Can drag a contiguous set of rows if dragging blue button
                     table.tableDnDConfig.dragObjects = [ row ]; // defaults to just the one
                     var btn = $( row ).find('p.btnBlue');  // btnBlue means cursor over left button
                     if (btn.length === 1) {
                         table.tableDnDConfig.dragObjects = dragReorder.getContiguousRowSet(row);
                         var compositeSet = dragReorder.getCompositeSet(row);
                         if (compositeSet && compositeSet.length > 0)
                             $( compositeSet ).find('p.btn').addClass('blueButtons');// blue persists
                     }
                 },
                 onDrop: function(table, row, dragStartIndex) {
                     var compositeSet = dragReorder.getCompositeSet(row);
                     if (compositeSet && compositeSet.length > 0)
                         $( compositeSet ).find('p.btn').removeClass('blueButtons');// blue persists
-                    if ($(row).attr('rowIndex') !== dragStartIndex) {
+                     // NOTE: As of jquery 1.6, attr() can no longer be used to get/set values
+                     // that are not explicitly attributes, instead prop() should be used instead.
+                     // However this can cause problems in our legacy code because prop() returns
+                     // undefined if the property was not set! rowIndex is a property set by
+                     // tableDnd so we must use prop() to check for it's value, not attr()
+                    let rowIndex = $(row).prop('rowIndex');
+                    if (typeof rowIndex !== "undefined" && rowIndex !== dragStartIndex) {
                         // NOTE Even if dragging a contiguous set of rows,
                         // still only need to check the one under the cursor.
                         if (dragReorder.setOrder) {
                             dragReorder.setOrder(table);
                         }
                         dragReorder.zipButtons( table );
                     }
                     $(document).off('mousemove',posting.blockTheMapOnMouseMove);
                     // Timeout necessary incase the onDrop over map item. onDrop takes precedence.
                     setTimeout(posting.allowMapClicks,100);
                 }
             });
         }
 
         // Drag scroll init