Skip to content

Commit

Permalink
perf(tree): reduce calculations for visible items
Browse files Browse the repository at this point in the history
  • Loading branch information
TremayneChrist committed Oct 22, 2021
1 parent 45a13a6 commit c231f06
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions packages/elements/src/tree/managers/tree-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ export class TreeManager<T extends TreeDataItem> {
*/
private getVisibleItems (items: readonly T[], result: T[] = []): T[] {
for (const item of items) {
if (this.isItemVisible(item)) {
result.push(item);
if (!this.isItemHidden(item) && result.push(item) && this.isItemExpanded(item)) {
const children = this.getItemChildren(item);
children.length && this.getVisibleItems(children, result);
}
Expand All @@ -126,17 +125,6 @@ export class TreeManager<T extends TreeDataItem> {
return this.composer.getItemPropertyValue(item, 'hidden') === true;
}

/**
* Is the item visible?
* @param item Original data item
* @returns `True` if the item is visible
*/
private isItemVisible (item: T): boolean {
return !this.isItemHidden(item)
&& !this.composer.getItemAncestors(item)
.some(ancestor => !this.isItemExpanded(ancestor));
}

/**
* Is the item checked?
* @param item Original data item
Expand Down

0 comments on commit c231f06

Please sign in to comment.