From 0922530e3bdfe6c10b1d3e4714de12bb392a596b Mon Sep 17 00:00:00 2001 From: Jordan Disch Date: Thu, 18 Feb 2021 15:50:07 +1100 Subject: [PATCH] made selectRowDelete function async --- package-lock.json | 2 +- src/MUIDataTable.js | 15 +++++++-------- src/components/TableHead.js | 1 - test/MUIDataTableToolbarCustomIcons.test.js | 6 ++---- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1f17524e7..ced6ed78d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mui-datatables", - "version": "3.7.2", + "version": "3.7.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/MUIDataTable.js b/src/MUIDataTable.js index 124a7bb99..384ffe770 100644 --- a/src/MUIDataTable.js +++ b/src/MUIDataTable.js @@ -1517,20 +1517,19 @@ class MUIDataTable extends React.Component { ); }; - selectRowDelete = () => { + selectRowDelete = async () => { const { selectedRows, data, filterList } = this.state; const selectedMap = buildMap(selectedRows.data); const cleanRows = data.filter(({ index }) => !selectedMap[index]); if (this.options.onRowsDelete) { - if ( - this.options.onRowsDelete( - selectedRows, - cleanRows.map(ii => ii.data), - ) === false - ) - return; + const assetsToDelete = await this.options.onRowsDelete( + selectedRows, + cleanRows.map(ii => ii.data), + ); + + if (assetsToDelete === false) return; } this.setTableData( diff --git a/src/components/TableHead.js b/src/components/TableHead.js index 08488b20c..86e61bc8f 100644 --- a/src/components/TableHead.js +++ b/src/components/TableHead.js @@ -6,7 +6,6 @@ import TableHeadCell from './TableHeadCell'; import TableHeadRow from './TableHeadRow'; import TableSelectCell from './TableSelectCell'; - const useStyles = makeStyles( theme => ({ main: {}, diff --git a/test/MUIDataTableToolbarCustomIcons.test.js b/test/MUIDataTableToolbarCustomIcons.test.js index c38e89313..ebac5bfbe 100644 --- a/test/MUIDataTableToolbarCustomIcons.test.js +++ b/test/MUIDataTableToolbarCustomIcons.test.js @@ -61,17 +61,16 @@ const data = [ const testCustomIcon = iconName => { const components = { icons: { [iconName]: CustomChip } }; - const wrapper = mount(); + const wrapper = mount(); assert.strictEqual(wrapper.find(IconButton).length, 5); // All icons show assert.strictEqual(wrapper.find(CustomChip).length, 1); // Custom chip shows once Object.keys(icons).forEach(icon => { // The original default for the custom icon should be gone, the rest should remain - assert.strictEqual(wrapper.find(icons[icon]).length, iconName === icon ? 0 : 1); + assert.strictEqual(wrapper.find(icons[icon]).length, iconName === icon ? 0 : 1); }); }; describe(' with custom icons', function() { - it('should render a toolbar with a custom chip in place of the search icon', () => { testCustomIcon('SearchIcon'); }); @@ -91,5 +90,4 @@ describe(' with custom icons', function() { it('should render a toolbar with a custom chip in place of the filter icon', () => { testCustomIcon('FilterIcon'); }); - });