File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,20 @@ export class TreeVirtualScroll {
144
144
} , firstIndex ) ;
145
145
146
146
const viewportNodes = [ ] ;
147
+
148
+ // Loading async top nodes' children is too long.
149
+ // It happens when first node is visible withing viewport range (including Y_OFFSET).
150
+ // In that case firstIndex == 0 and lastIndex == visibleNodes.length - 1 (e.g. 1000),
151
+ // which means that it loops through every visibleNodes item and push them into viewportNodes array.
152
+ // lastIndex should not equal visibleNodes.length - 1, but something around 50-100 (depending on the viewport)
153
+ const nodeHeight = visibleNodes [ 0 ] . treeModel . options . options . nodeHeight ;
154
+ const renderedNodesMaxLength = ( Y_OFFSET * 2 + this . viewportHeight ) / nodeHeight ;
155
+
156
+ // Something is probably wrong, prevent nodes from being pushed to an array.
157
+ if ( lastIndex - firstIndex > renderedNodesMaxLength ) {
158
+ return [ ] ;
159
+ }
160
+
147
161
for ( let i = firstIndex ; i <= lastIndex ; i ++ ) {
148
162
viewportNodes . push ( visibleNodes [ i ] ) ;
149
163
}
You can’t perform that action at this time.
0 commit comments