material-table icon indicating copy to clipboard operation
material-table copied to clipboard

onRowClick doesn't allow to copy/highlight string value

Open buhrenduh opened this issue 6 years ago • 2 comments

Describe the bug When implementing onRowClick, if I attempt to copy the string value by clicking and highlighting, the onClick action triggers. In my case, the onRowClick opens up a new page so I am not able to copy the string value. In my screenshot, I am trying to copy the date.

To Reproduce Steps to reproduce the behavior:

  1. Implement onRowClick that opens a new page
  2. Highlight a string value in one of the columns

Expected behavior I should be able to highlight/copy string values/text from the row without triggering the onRowClick event.

Example, in material-ui (https://v3.material-ui.com/demos/tables/) if you go to Sorting & Selecting examples, there is an event click on the row, but I am also able to select and highlight the string.

Screenshots I can't show the whole table, but onRowClick, this will open another page. 2020-02-19_12-43-56 (1)

Desktop (please complete the following information):

  • OS: [e.g. iOS] macOS
  • Browser [e.g. chrome, safari]: Chrome
  • Version [e.g. 22]: 80.0.3987.106

Additional context I don't know if it's a bug but it would definitely be an appreciated feature!

buhrenduh avatar Feb 19 '20 20:02 buhrenduh

I don't think that's related to material-table. But here's it what you can do to fix it.

const handleOnClick = () => {
    const selection = window.getSelection().toString()
    if (selection.length <= 0) {
      doSomething();
    }
}

jonasanx avatar Feb 20 '20 19:02 jonasanx

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Jul 05 '20 20:07 stale[bot]