mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 21:08:55 +08:00
fix: Nav无法展开、高亮不同步问题修复 (#6182)
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
This commit is contained in:
parent
32412ff1fd
commit
927c358b78
@ -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'
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user