primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.97k stars 1.06k forks source link

Change in DataTable's Tablebody onRowMouseDown event implies that all rows are draggable #7332

Open feg3jvl opened 1 month ago

feg3jvl commented 1 month ago

We are having a specific problem in the TableBody implementation that implies that all the rows in the table are draggable, and that the draggable attribute is not being read and resolving the situation. In my implementation, the attribute dragSelection is false. We tried to passtrought in all the layers (table, tablebody, columns, etc) the attribute draggable as false, but without success.

In the DataTable documentation itself, all the tables without exception have the same behaviour (I wasn't able to attach a file here). The scenario is simply try to copy the content of a cell in the DataTable. (https://primereact.org/datatable/)

In my investigation of the issues, looks like that the commit above is causing the issue. The isDraggableHandle within onRowMouseDown is what appears to be the root cause of the problem, as it only considers the p-datatable-reorderablerow-handle class. https://github.com/primefaces/primereact/blame/fb0305717f1ff05bf9a521b70208087fdd8d7995/components/lib/datatable/TableBody.js#L595

As a workaround that I found to resolve the issue, in case you don't need the onRowMouseDown event, is to capture the event and stop the propagation:

  <PrimeDataTable onMouseDownCapture={(e) => { e.stopPropagation(); }}>
...

But this is not the ideal way to fix it. If you guys have a better alternative, I would be glad to see. But I think this should be resolved, because the draggable attribute is missleading in this case. The main attribute to use that drag and drop should be at the table level the dragSelection and via props the draggable.

melloware commented 1 month ago

Related to: https://github.com/primefaces/primereact/issues/7321