From f8a3fedbb29d9302f7a1bcc76157ca45a05d22de Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sat, 29 Sep 2018 15:29:42 +0800 Subject: [PATCH] fix #564 --- packages/react-bootstrap-table2/src/bootstrap-table.js | 1 + .../src/contexts/row-expand-context.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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); }