From 8f304a849f7840cfedcddf9e5ee7143788adc74a Mon Sep 17 00:00:00 2001 From: Yassien <11986226+YassienW@users.noreply.github.com> Date: Sat, 16 Mar 2019 19:03:22 +0200 Subject: [PATCH] Animation now works with custom expand management --- .../src/contexts/row-expand-context.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 ba21d12..601c338 100644 --- a/packages/react-bootstrap-table2/src/contexts/row-expand-context.js +++ b/packages/react-bootstrap-table2/src/contexts/row-expand-context.js @@ -17,8 +17,16 @@ class RowExpandProvider extends React.Component { componentWillReceiveProps(nextProps) { if (nextProps.expandRow) { + const isClosing = this.state.expanded.reduce((acc, cur) => { + if (!nextProps.expandRow.expanded.includes(cur)) { + acc.push(cur); + } + return acc; + }, []); + this.setState(() => ({ expanded: nextProps.expandRow.expanded, isClosing })); + } else { this.setState(() => ({ - expanded: nextProps.expandRow.expanded || this.state.expanded + expanded: this.state.expanded })); } }