Skip to content

[WC-3163] Allow treenode to have self reference association for infinite level of children#2056

Open
gjulivan wants to merge 3 commits intomainfrom
treenode-recursive
Open

[WC-3163] Allow treenode to have self reference association for infinite level of children#2056
gjulivan wants to merge 3 commits intomainfrom
treenode-recursive

Conversation

@gjulivan
Copy link
Collaborator

@gjulivan gjulivan commented Feb 3, 2026

Added parent association property to allow treenode to have infinite levels of children by setting up property to a self reference association.

@gjulivan gjulivan requested a review from a team as a code owner February 3, 2026 13:28
@gjulivan gjulivan changed the title chore: allow treenode to have self reference association [WC-3163] Allow treenode to have self reference association for infinite level of children Feb 3, 2026
@gjulivan gjulivan force-pushed the treenode-recursive branch 5 times, most recently from 123cfa3 to 5b56842 Compare February 4, 2026 08:39

// retrieve new datasource for array of items
// this is used for checking children's of children (grandchildren) when a branch is expanded
const filterContents = useCallback(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this can be inlined into filterContent

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better be a helper function that gets everything as an argument.

Comment on lines +82 to +83
// ignore "datasource" update triggering fetchChildren again
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use anything except setFilter, maybe we can keep and check reference to it instead of ignoring whole datasource. This way we are safe if reference ever changes but don't get triggered on any datasource update.

Comment on lines +71 to +80
if (isInfiniteTreeNodesEnabled && fetchingItem.current === undefined) {
resolvePromise.current = resolve;
if (Array.isArray(item)) {
fetchingItem.current = item[0];
} else {
fetchingItem.current = item;
}
datasource.setFilter(filterContent(item));
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it going to be a never-resolving promise if a fetch is already in progress?

Copy link
Collaborator

@r0b1n r0b1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try decoupling the fetching/filtering logic from the react part as this if so hard to follow what is happening and makes complexity of react lifecycle add up with lifecycle of data sources.

);

// retrieve new datasource for array of items
// this is used for checking children's of children (grandchildren) when a branch is expanded
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is so. Aren't we already holding all the previous levels already when we expand one level deeper?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants