From 6c433d51a3030fd13ffe20eb69c4fcca64e3483b Mon Sep 17 00:00:00 2001 From: Caleb Jones Date: Thu, 8 Mar 2018 15:16:07 -0500 Subject: [PATCH] fix: recalculate rowHeight() when isVirualized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When rendering rows with isVirualized, if rowHeight is a func, the virtualized list was not recalculating the rowHeight. Per the `react-virtualized` docs [here](https://github.com/bvaughn/react-virtualized/blob/master/docs/Lis t.md#recomputerowheights-index-number), `List.recomputeRowHeights()` needs to be called. This only fixes the dynamic rowHeight issue _after_ dragging a node is finished. An additional `List.recomputeRowHeights()` will need to be called to fix the ‘preview’ while dragging a row (see issue below for more details). This partially fixes [Issue 264](https://github.com/fritz-c/react-sortable-tree/issues/264). --- src/react-sortable-tree.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/react-sortable-tree.js b/src/react-sortable-tree.js index 6dac1382..665c15d9 100644 --- a/src/react-sortable-tree.js +++ b/src/react-sortable-tree.js @@ -235,6 +235,8 @@ class ReactSortableTree extends Component { getNodeKey: this.props.getNodeKey, }); + this.scrollZoneVirtualListComponent.wrappedInstance.recomputeRowHeights(); + this.props.onChange(treeData); this.props.onMoveNode({ @@ -634,6 +636,9 @@ class ReactSortableTree extends Component { {({ height, width }) => ( { + this.scrollZoneVirtualListComponent = el + }} verticalStrength={this.vStrength} horizontalStrength={this.hStrength} speed={30}