diff --git a/packages/react-bootstrap-table2/src/bootstrap-table.js b/packages/react-bootstrap-table2/src/bootstrap-table.js index 75b7e4f..b0d4779 100644 --- a/packages/react-bootstrap-table2/src/bootstrap-table.js +++ b/packages/react-bootstrap-table2/src/bootstrap-table.js @@ -166,6 +166,7 @@ BootstrapTable.propTypes = { onExpandAll: PropTypes.func, nonExpandable: PropTypes.array, showExpandColumn: PropTypes.bool, + onlyOneExpanding: PropTypes.bool, expandColumnRenderer: PropTypes.func, expandHeaderColumnRenderer: PropTypes.func }), diff --git a/packages/react-bootstrap-table2/src/contexts/row-expand-context.js b/packages/react-bootstrap-table2/src/contexts/row-expand-context.js index d6b1702..3e882c6 100644 --- a/packages/react-bootstrap-table2/src/contexts/row-expand-context.js +++ b/packages/react-bootstrap-table2/src/contexts/row-expand-context.js @@ -25,12 +25,13 @@ export default ( } handleRowExpand = (rowKey, expanded, rowIndex, e) => { - const { data, keyField, expandRow: { onExpand } } = this.props; + const { data, keyField, expandRow: { onExpand, onlyOneExpanding } } = this.props; let currExpanded = [...this.state.expanded]; if (expanded) { - currExpanded.push(rowKey); + if (onlyOneExpanding) currExpanded = [rowKey]; + else currExpanded.push(rowKey); } else { currExpanded = currExpanded.filter(value => value !== rowKey); }