From a1996ffc18286b51b4011f143f482b1dd14c124c Mon Sep 17 00:00:00 2001 From: Gregory Bell Date: Tue, 4 Apr 2017 17:15:19 -0600 Subject: [PATCH] Fixing problem with externally controlling expanded rows. Changing the "expanding" option was not changing which rows were selected. Setting an initial list of expanded rows worked, but modifying that list through the props to BootstrapTable did not work. The value being passed down to TableBody is `this.state.expanding`, but that is only set from props as part of the constructor, so changes to props.options.expanding of an already mounted BootstrapTable weren't being taken into account. I've added some handling in componentWillReceiveProps to deal with change to `options.expanding`. I've copied the pattern used for the pagination options. --- src/BootstrapTable.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/BootstrapTable.js b/src/BootstrapTable.js index 50ce8b923..18a42b3ab 100644 --- a/src/BootstrapTable.js +++ b/src/BootstrapTable.js @@ -240,6 +240,14 @@ class BootstrapTable extends Component { }); } + // If setting the expanded rows is being handled externally + // then overwrite the current expanded rows. + if (this.props.options.expanding !== options.expanding) { + this.setState({ + expanding: options.expanding || [] + }); + } + if (selectRow && selectRow.selected) { // set default select rows to store. const copy = selectRow.selected.slice();