bito-code-review[bot] commented on PR #44069:
URL: https://github.com/apache/superset/pull/44069#issuecomment-5607780354
<!-- Bito Reply -->
The current implementation of `resolveTransitiveChildIds` correctly
identifies all transitive descendants in the dependency graph, which is the
intended behavior for cascading clears. The `cascadeClearTrigger` mechanism in
`PluginFilterSelect` ensures that when a parent filter changes, all identified
descendants are reset, mirroring the global `clearAll` behavior. If a child
filter is out-of-scope, it is still a logical descendant in the dependency
chain, and resetting its state is necessary to maintain data consistency across
the dashboard.
**superset-frontend/src/dashboard/components/nativeFilters/dependencyGraph.ts**
```
export function resolveTransitiveChildIds(
id: string,
filterConfig: FilterConfigMap,
): string[] {
const childrenByParent = new Map<string, string[]>();
Object.entries(filterConfig).forEach(([childId, filter]) => {
ensureIsArray(filter?.cascadeParentIds).forEach((parentId: string) => {
const siblings = childrenByParent.get(parentId) ?? [];
siblings.push(childId);
childrenByParent.set(parentId, siblings);
});
});
const ordered: string[] = [];
const visited = new Set<string>([id]);
const queue = [id];
while (queue.length > 0) {
const currentId = queue.shift()!;
const children = childrenByParent.get(currentId) ?? [];
children.forEach(childId => {
if (visited.has(childId)) return;
visited.add(childId);
ordered.push(childId);
queue.push(childId);
});
}
return ordered;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]