Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Issues
  • #770
Closed
Open
Issue created Mar 09, 2017 by Administrator@rootContributor

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);
});
Assignee
Assign to
Time tracking