Suggestion: Disable click event on text selection in index tables
Created by: stevenmilton58
Version: 0.4.0
On the index page of a give resource, it is currently not possible to select some information from the table without navigating away from the index page.
Mouse down+drag to select text+mouse up causes navigation to occur when the intent was only to copy text, and not click. Examples
One fix would be to change the code in https://github.com/thoughtbot/administrate/blob/v0.4.0/app/assets/javascripts/administrate/components/table.js to:
$(function() {
var keycodes = { space: 32, enter: 13 };
var visitDataUrl = function(event) {
if (event.type=="click" ||
event.keyCode == keycodes.space ||
event.keyCode == keycodes.enter) {
var selection = window.getSelection().toString(); // code added
if (selection.length == 0) { // code added
if(!event.target.href) {
window.location = $(event.target).closest("tr").data("url");
}
}
}
};
$("table").on("click", ".table__row", visitDataUrl);
$("table").on("keydown", ".table__row", visitDataUrl);
});