Skip to content

Commit

Permalink
fix zuiidea#372 update navOpenKeys when copy link open
Browse files Browse the repository at this point in the history
  • Loading branch information
superlbr committed May 5, 2018
1 parent 07b2175 commit c66f086
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/Layout/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { Link } from 'react-router-dom'
import { arrayToTree, queryArray } from 'utils'
import pathToRegexp from 'path-to-regexp'

const { SubMenu } = Menu
let openKeysFlag = false

const Menus = ({
siderFold, darkTheme, navOpenKeys, changeOpenKeys, menu, location,
}) => {
Expand All @@ -20,15 +23,15 @@ const Menus = ({
levelMap[item.id] = item.mpid
}
return (
<Menu.SubMenu
<SubMenu
key={item.id}
title={<span>
{item.icon && <Icon type={item.icon} />}
{(!siderFoldN || !menuTree.includes(item)) && item.name}
</span>}
>
{getMenus(item.children, siderFoldN)}
</Menu.SubMenu>
</SubMenu>
)
}
return (
Expand Down Expand Up @@ -62,6 +65,7 @@ const Menus = ({
}

const onOpenChange = (openKeys) => {
if (navOpenKeys.length) changeOpenKeys([]), openKeysFlag = true
const latestOpenKey = openKeys.find(key => !navOpenKeys.includes(key))
const latestCloseKey = navOpenKeys.find(key => !openKeys.includes(key))
let nextOpenKeys = []
Expand All @@ -85,6 +89,7 @@ const Menus = ({
let defaultSelectedKeys
for (let item of menu) {
if (item.route && pathToRegexp(item.route).exec(location.pathname)) {
if (!navOpenKeys.length && item.mpid && !openKeysFlag) changeOpenKeys([String(item.mpid)])
currentMenu = item
break
}
Expand Down

0 comments on commit c66f086

Please sign in to comment.