9a1633df43738cc9bb0b64ad932514ffaae85895 braney Mon Aug 10 17:17:12 2026 -0700 hgTracks: start the drag-select color picker on the saved color, refs #37990 Checking "don't show this again" makes the dialog's close handler remove it from the DOM rather than hide it, so the next drag builds a new one. The rebuilt picker took the default color and the color the user had saved was gone. The dialog saves its color with dragSelect.saveHlColor, which writes hgTracks.prevHlColor. makeHighlightPicker reads a prevHlColor of its own, which nothing in this path ever sets, so it fell through to the default. Pass the saved color in as the picker's starting color. Leave the fourth argument undefined so the label keeps its default: the label test reads label.length, so passing null there would throw. Without the checkbox the dialog is only hidden and keeps its value, which is why this was hard to reproduce from the report. diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 60cf3fc3c5c..b390265ae5f 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -2245,31 +2245,38 @@ if (dragSelect.startTime===null) return; var dragSelectDialog = $("#dragSelectDialog")[0]; if (!dragSelectDialog) { $("body").append("<div id='dragSelectDialog'>" + "<p><ul>"+ "<li>Hold <b>Shift+drag</b> to show this dialog" + "<li>Hold <b>Alt+drag</b> (Windows) or <b>Option+drag</b> (Mac) to add a highlight" + "<li>Hold <b>Ctrl+drag</b> (Windows) or <b>Cmd+drag</b> (Mac) to zoom" + "<li>To cancel, press <tt>Esc</tt> anytime during the drag" + "<li>Using the keyboard, highlight the current position with <tt>h then m</tt>" + "<li>Clear all highlights with View - Clear Highlights or <tt>h then c</tt>" + "<li>Clear specific highlights with right click > Remove highlight" + "<li>To merely save the color for the next keyboard or right-click > Highlight operations, click 'Save Color' below" + "</ul></p>"); - makeHighlightPicker("hlColor", document.getElementById("dragSelectDialog"), null); + // Start the picker on the color the user last saved. This dialog is removed from + // the DOM on close when "don't show this again" is checked, so this runs again on + // the next drag. makeHighlightPicker's own loadHlColor() reads a different + // prevHlColor than the one dragSelect.saveHlColor writes, so without the color + // passed in here the rebuilt picker falls back to the default and the saved color + // is lost. Fourth argument stays undefined so the label keeps its default. + makeHighlightPicker("hlColor", document.getElementById("dragSelectDialog"), null, + undefined, dragSelect.loadHlColor()); $("#dragSelectDialog").append("<div style='padding-top: 4px'><input style='float:left' type='checkbox' id='disableDragHighlight'>" + "<span style='border:solid 1px #DDDDDD; padding:3px;display:inline-block' id='hlNotShowAgainMsg'>Don't show this again and always zoom with shift.<br>" + "Re-enable via 'View - Configure Browser' (<tt>c then f</tt>)</span></div>"+ "Selected chromosome position: <span id='dragSelectPosition'></span>"); dragSelectDialog = $("#dragSelectDialog")[0]; // reset value // allow to click checkbox by clicking on the label $('#hlNotShowAgainMsg').on("click", function() { $('#disableDragHighlight').trigger("click");}); // click "add highlight" when enter is pressed in color input box $("#hlColorInput").on("keyup", function(event){ if(event.keyCode == 13){ $(".ui-dialog-buttonset button:nth-child(3)").trigger("click"); } }); }