diff --git a/package-lock.json b/package-lock.json index 2f078db..a4103aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@hi-ui/classic-theme", - "version": "4.0.3-beta.2", + "version": "4.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c2c71e8..7a6c2f2 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hi-ui/classic-theme", - "version": "4.0.3", + "version": "4.0.4", "description": "Classic theme for HIUI", "main": "./es/index.js", "scripts": { diff --git a/src/hooks/useMenuCalculator.js b/src/hooks/useMenuCalculator.js index 78405ec..a900e2c 100644 --- a/src/hooks/useMenuCalculator.js +++ b/src/hooks/useMenuCalculator.js @@ -58,7 +58,7 @@ const useMenuCalculator = (menu, location, history, fallback, onMenuClick, disab const activeMenuId = useMemo(() => { if (!currentMenu.name) { - return getNamedParent(currentMenu.path, menu).id + return getNamedParent(currentMenu.path, menu)?.id ?? '' } else { return currentMenu.id } diff --git a/src/util/common.js b/src/util/common.js index 9679d6e..62b415b 100644 --- a/src/util/common.js +++ b/src/util/common.js @@ -70,6 +70,7 @@ export const getAncestor = (path, data, arr = []) => { // 寻找某一节点具有 name 属性的祖先节点 export const getNamedParent = (path, data) => { const parent = getParent(path, data) + if (!parent) return null if (!parent.name) { return getNamedParent(parent.path, data) } else {