diff --git a/packages/react-bootstrap-table2/src/store/selection.js b/packages/react-bootstrap-table2/src/store/selection.js index 7d3e741..135651d 100644 --- a/packages/react-bootstrap-table2/src/store/selection.js +++ b/packages/react-bootstrap-table2/src/store/selection.js @@ -41,5 +41,5 @@ export const unSelectableKeys = (selected, skips = []) => { }; export const getSelectedRows = (data, keyField, selected) => - selected.map(k => getRowByRowId(data, keyField, k)); + selected.map(k => getRowByRowId(data, keyField, k)).filter(x => !!x); diff --git a/packages/react-bootstrap-table2/test/store/selection.test.js b/packages/react-bootstrap-table2/test/store/selection.test.js index bed3f30..4986544 100644 --- a/packages/react-bootstrap-table2/test/store/selection.test.js +++ b/packages/react-bootstrap-table2/test/store/selection.test.js @@ -45,6 +45,14 @@ describe('Selection Function', () => { expect(result).toHaveLength(selected.length); expect(result).toEqual(data); }); + + describe('if can not find the row', () => { + describe('should just skip it', () => { + const selected = [1, 4, 6, 7]; + const result = getSelectedRows(data, keyField, selected); + expect(result).toHaveLength(2); + }); + }); }); describe('getSelectionSummary', () => {