Skip to content

Commit

Permalink
fix(menu): do not skip children if not generated in prev step
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Malkevich committed Mar 28, 2019
1 parent 094b6fc commit f908039
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions projects/dynamic-menu/src/lib/dynamic-menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,15 @@ export class DynamicMenuService implements OnDestroy {
res.node,
children,
cb,
) as T[];

return res.acc
? [...res.acc, ...childrenInRoot]
: [...acc, ...childrenInRoot];
) as T[] | undefined;

if (childrenInRoot) {
return res.acc
? [...res.acc, ...childrenInRoot]
: [...acc, ...childrenInRoot];
} else {
return res.acc ? res.acc : acc;
}
}
} else if (isConfigMenuItem(res.node)) {
this.visitMenuChildren(res.node, children, cb);
Expand All @@ -369,14 +373,14 @@ export class DynamicMenuService implements OnDestroy {
children: AnyMenuRoute[],
cb: MenuVisitor<AnyMenuRoute>,
parentNode: AnyMenuRoute = node,
): AnyMenuRoute[] {
const newChildren = this.visitMenu(children, cb, parentNode) as any;
): AnyMenuRoute[] | undefined {
const newChildren = this.visitMenu(children, cb, parentNode);

if (!getMenuChildren(node) && newChildren) {
setMenuChildren(node, newChildren);
if (!getMenuChildren(node) && newChildren.length) {
setMenuChildren(node, newChildren as DynamicMenuRouteConfig[]);
}

return newChildren || [];
return newChildren.length ? newChildren : undefined;
}

private combineMenuWithCustom(
Expand Down

0 comments on commit f908039

Please sign in to comment.