6f0e8cf11dd3ead8170cf978f2587b768bc1d55a max Mon Oct 10 06:58:07 2022 -0700 finally was able to reproduce a bug I've observed a few times: the event listener on SVGs does not always return the SVG but can also return the PATH element as the target, depending on where the user clicks. This lead to non-working copy click handler on the SVG icon. Fixed now. refs #29583 diff --git src/hg/js/hgHubConnect.js src/hg/js/hgHubConnect.js index 6f262ea..a3e7bd3 100644 --- src/hg/js/hgHubConnect.js +++ src/hg/js/hgHubConnect.js @@ -100,32 +100,32 @@ } }); $('#hubDbFilter').bind('keypress', function(e) { // binds listener to text field if (e.which === 13) { // listens for return key e.preventDefault(); // prevents return from also submitting whole form $('input[name="hubSearchButton"]').focus().click(); // clicks db filter button } }); $('.pasteIcon').bind('click', function(e) { // The hgTracks link is in the <A> element two elements before the icon SVG: // <td> // <a class='hgTracksLink' href="hgTracks?hubUrl=https://hgwdev-kent.gi.ucsc.edu/~kent/t2t/hub/hub2.txt&genome=hub_25068_GCA_009914755&position=lastDbPos">GCA_009914755</a> // <input type="hidden" value="https://hgwdev-kent.gi.ucsc.edu/~kent/t2t/hub/hub2.txt"> // <svg class="pasteIcon">...</svg> <--- this is e.target of the click handler // </td> - var inputEl = e.target.previousSibling; - var connectUrl = e.target.previousSibling.previousSibling.href; + var inputEl = e.target.closest("svg").previousSibling; + var connectUrl = inputEl.previousSibling.href; // the url is in the <input> element just before the SVG var oldVal = inputEl.value; // display:none does not work, // see https://stackoverflow.com/questions/31593297/using-execcommand-javascript-to-copy-hidden-text-to-clipboard inputEl.style = "position: absolute; left: -1000px; top: -1000px"; inputEl.value = connectUrl; inputEl.type = 'text'; inputEl.select(); inputEl.setSelectionRange(0, 99999); /* For mobile devices */ document.execCommand('copy'); inputEl.type = 'hidden'; inputEl.value = oldVal; alert("Copied Genome Browser hub connection URL to clipboard");