fix: Nav无法展开、高亮不同步问题修复 (#6182)

Co-authored-by: wanglinfang <wanglinfang@baidu.com>
This commit is contained in:
wanglinfang2014 2023-02-16 10:48:43 +08:00 committed by GitHub
parent 32412ff1fd
commit 927c358b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 15 deletions

View File

@ -428,8 +428,15 @@ export class Menu extends React.Component<MenuProps, MenuState> {
props: SubMenuProps;
}) {
const {navigations} = this.state;
const {stacked, mode, collapsed, accordion, onToggleExpand, onToggle} =
this.props;
const {
stacked,
mode,
collapsed,
accordion,
onToggleExpand,
onToggle,
onSelect
} = this.props;
const isVericalInline = stacked && mode === 'inline' && !collapsed;
let openKeys = this.state.openKeys.concat();
@ -449,6 +456,8 @@ export class Menu extends React.Component<MenuProps, MenuState> {
// 因为Nav里只处理当前菜单项 因此新增一个onToggle事件
onToggle?.(currentItem?.link, keyPaths.length, isOpen);
onToggleExpand?.(uniq(openKeys));
onSelect?.(currentItem?.link || currentItem, keyPaths.length);
}
@autobind
@ -598,11 +607,8 @@ export class Menu extends React.Component<MenuProps, MenuState> {
onDragStart
} = this.props;
const {navigations, activeKey, defaultOpenKeys, openKeys} = this.state;
const isDarkTheme = themeColor === 'dark';
const disabledItem = findTree(navigations, item => !!item.disabled);
const rcMode = stacked
? mode === 'float'
? 'vertical-right'

View File

@ -821,11 +821,12 @@ const ConditionBuilderWithRemoteOptions = withRemoteConfig({
};
item.unfolded =
isUnfolded(item, {unfoldedField, foldedField}) ||
(link.children &&
!!findTree(link.children, (child, i, d) =>
isActive(child, depth + d)
));
typeof link.unfolded !== 'undefined'
? isUnfolded(item, {unfoldedField, foldedField})
: link.children &&
!!findTree(link.children, (child, i, d) =>
isActive(child, depth + d)
);
return item;
},
@ -978,7 +979,7 @@ const ConditionBuilderWithRemoteOptions = withRemoteConfig({
} else {
updateConfig(
mapTree(config, (link: Link) =>
target === link
target.__id === link.__id
? {
...link,
unfolded:
@ -996,10 +997,6 @@ const ConditionBuilderWithRemoteOptions = withRemoteConfig({
'toggle'
);
}
// 如果父菜单项也配置了链接 同样要支持跳转
if (target.to) {
this.handleSelect(target, depth);
}
}
async dragUpdate(dropInfo: IDropInfo) {