Skip to content

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

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

[WC-3163] Allow treenode to have self reference association for infinite level of children#2056
gjulivan wants to merge 6 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
@gjulivan gjulivan force-pushed the treenode-recursive branch 2 times, most recently from 0c323c4 to 440a0b9 Compare February 11, 2026 13:53

// 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated as inline code

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

Copy link
Collaborator

Choose a reason for hiding this comment

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

I expect // eslint-disable-next-line should go now.

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 Author

Choose a reason for hiding this comment

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

it will resolved when datasource.status === ValueStatus.Available

Copy link
Collaborator

Choose a reason for hiding this comment

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

If a fetch is already in progress and not finished yet and a fetch is called again, then fetchingItem.current === undefined is false (because previous didn't resolve) so the current promise will hang forever because resolve callback never assigned anywhere and wont be called.

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?

Copy link
Collaborator Author

@gjulivan gjulivan Feb 19, 2026

Choose a reason for hiding this comment

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

this is needed to "automatically" find out if a children is "hasChildren" and expandable, or not,
thus we can hide the property "hasChildren" in infinite treenode.

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

Comments