nav 父节点的 unfolded 需要依赖子节点的 active (#1960)

Co-authored-by: cy <chenyi08@kuaishou.com>
This commit is contained in:
cyboning 2021-05-14 14:35:50 +08:00 committed by GitHub
parent bad661528a
commit d94fbddeb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -231,27 +231,32 @@ const ConditionBuilderWithRemoteOptions = withRemoteConfig({
if (Array.isArray(links) && motivation !== 'toggle') {
const {data, env, unfoldedField, foldedField} = props;
links = mapTree(links, (link: Link) => {
const item: any = {
...link,
...getExprProperties(link, data as object),
active:
(motivation !== 'location-change' && link.active) ||
(link.activeOn
? evalExpression(link.activeOn as string, data)
: !!(
link.hasOwnProperty('to') &&
env &&
env.isCurrentUrl(filter(link.to as string, data))
))
};
links = mapTree(
links,
(link: Link) => {
const item: any = {
...link,
...getExprProperties(link, data as object),
active:
(motivation !== 'location-change' && link.active) ||
(link.activeOn
? evalExpression(link.activeOn as string, data)
: !!(
link.hasOwnProperty('to') &&
env &&
env.isCurrentUrl(filter(link.to as string, data))
))
};
item.unfolded =
isUnfolded(item, {unfoldedField, foldedField}) ||
(link.children && link.children.some(link => !!link.active));
item.unfolded =
isUnfolded(item, {unfoldedField, foldedField}) ||
(link.children && link.children.some(link => !!link.active));
return item;
});
return item;
},
1,
true
);
}
return links;