From 7df02d0198e2dc6de18e10b88bb7b384c107c8b8 Mon Sep 17 00:00:00 2001 From: Jared Scott Date: Thu, 19 Sep 2024 11:30:42 +0800 Subject: [PATCH 1/2] fix: #7200 Fix Drag Selection for Datatable --- components/lib/datatable/TableBody.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lib/datatable/TableBody.js b/components/lib/datatable/TableBody.js index 2a86b36dff..deef394622 100644 --- a/components/lib/datatable/TableBody.js +++ b/components/lib/datatable/TableBody.js @@ -151,7 +151,7 @@ export const TableBody = React.memo( }; const allowRowDrag = (event) => { - return (!allowCellSelection() && allowDrag(event)) || props.reorderableRows; + return (!allowCellSelection() && allowDrag({ originalEvent: event })) || props.reorderableRows; }; const allowCellDrag = (event) => { From f17a5c1b5e17516e46edf1785492f81d05d26864 Mon Sep 17 00:00:00 2001 From: Jared Scott Date: Thu, 19 Sep 2024 14:16:24 +0800 Subject: [PATCH 2/2] fix: #7200 Don't restructure `originalEvent` in `allowRowDrag`, just pass the full event through from `onRowDragStart` --- components/lib/datatable/TableBody.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/lib/datatable/TableBody.js b/components/lib/datatable/TableBody.js index deef394622..aefc7a0836 100644 --- a/components/lib/datatable/TableBody.js +++ b/components/lib/datatable/TableBody.js @@ -151,7 +151,7 @@ export const TableBody = React.memo( }; const allowRowDrag = (event) => { - return (!allowCellSelection() && allowDrag({ originalEvent: event })) || props.reorderableRows; + return (!allowCellSelection() && allowDrag(event)) || props.reorderableRows; }; const allowCellDrag = (event) => { @@ -668,7 +668,7 @@ export const TableBody = React.memo( const onRowDragStart = (e) => { const { originalEvent: event, index } = e; - if (allowRowDrag(event)) { + if (allowRowDrag(e)) { rowDragging.current = true; draggedRowIndex.current = index; event.dataTransfer.setData('text', 'b'); // For firefox