From 96fe9d614d422a934c27caee98ffcaf5187ea686 Mon Sep 17 00:00:00 2001 From: pem Date: Tue, 1 Oct 2019 11:48:50 +0200 Subject: [PATCH] code enhancement: rewrote list inclusion and list merge --- packages/ra-ui-materialui/src/list/Datagrid.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/ra-ui-materialui/src/list/Datagrid.js b/packages/ra-ui-materialui/src/list/Datagrid.js index 0db4a4ea9df..add6affa3ad 100644 --- a/packages/ra-ui-materialui/src/list/Datagrid.js +++ b/packages/ra-ui-materialui/src/list/Datagrid.js @@ -138,12 +138,7 @@ function Datagrid({ classes: classesOverride, ...props }) { event => { if (event.target.checked) { onSelect( - ids.reduce( - (idList, id) => - idList.includes(id) ? idList : idList.concat(id), - - selectedIds - ) + ids.concat(selectedIds.filter(id => !ids.includes(id))) ); } else { onSelect([]); @@ -206,9 +201,7 @@ function Datagrid({ classes: classesOverride, ...props }) { checked={ selectedIds.length > 0 && ids.length > 0 && - !ids.find( - it => selectedIds.indexOf(it) === -1 - ) + ids.every(id => selectedIds.includes(id)) } onChange={handleSelectAll} />