From 1c9703d9e44275d745d6e49e5733be2cb0a816da Mon Sep 17 00:00:00 2001 From: jeffvli Date: Thu, 23 Sep 2021 03:38:13 -0700 Subject: [PATCH] Add debounce function for drag multiselect To handle larger lists, a short debounce will increase performance --- src/components/viewtypes/ListViewTable.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/viewtypes/ListViewTable.tsx b/src/components/viewtypes/ListViewTable.tsx index 3d185bc..66c9375 100644 --- a/src/components/viewtypes/ListViewTable.tsx +++ b/src/components/viewtypes/ListViewTable.tsx @@ -168,12 +168,16 @@ const ListViewTable = ({ // If mouse is still held down from the handleSelectMouseDown function, then // mousing over a row will set the range selection from the initial mousedown location // to the mouse-entered row + const debouncedMouseEnterFn = _.debounce((rowData: any) => { + dispatch(setRangeSelected(rowData)); + dispatch( + toggleRangeSelected(sortColumn && !nowPlaying ? sortedData : data) + ); + }, 100); + const handleSelectMouseEnter = (rowData: any) => { if (multiSelect.isSelectDragging) { - dispatch(setRangeSelected(rowData)); - dispatch( - toggleRangeSelected(sortColumn && !nowPlaying ? sortedData : data) - ); + debouncedMouseEnterFn(rowData); } };