@@ -9,7 +9,11 @@ import Tree, {
99 TreeState ,
1010 UpdateOptions ,
1111} from './Tree' ;
12- import { shouldUpdateRecords , updateRecord , updateRecordOnWalk } from './utils' ;
12+ import {
13+ shouldUpdateRecords ,
14+ updateRecord ,
15+ updateRecordOnNewData ,
16+ } from './utils' ;
1317
1418export type VariableSizeNodeData = Readonly < {
1519 /** Default node height. Can be used only with VariableSizeTree */
@@ -94,8 +98,8 @@ const computeTree = createTreeComputer<
9498 updateRecord ( record , recordId , options ) ;
9599 } ,
96100
97- updateRecordOnWalk : ( record , options ) => {
98- updateRecordOnWalk ( record , options ) ;
101+ updateRecordOnNewData : ( record , options ) => {
102+ updateRecordOnNewData ( record , options ) ;
99103
100104 if ( options . useDefaultHeight ) {
101105 record . height = record . data . defaultHeight ;
@@ -132,6 +136,14 @@ export class VariableSizeTree<T extends VariableSizeNodeData> extends Tree<
132136 ) ;
133137 }
134138
139+ public recomputeTree ( options ?: VariableSizeUpdateOptions ) : Promise < void > {
140+ return super . recomputeTree ( options ) . then ( ( ) => {
141+ if ( options ?. useDefaultHeight ) {
142+ this . list . current ?. resetAfterIndex ( 0 , true ) ;
143+ }
144+ } ) ;
145+ }
146+
135147 public render ( ) : ReactNode {
136148 const { children, itemSize, rowComponent, treeWalker, ...rest } = this . props ;
137149
0 commit comments