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