Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: active wrong when submenus has key '' #721

Merged
merged 5 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/hooks/useKeyRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,18 @@ export default function useKeyRecords() {
);

const isSubPathKey = useCallback(
(pathKeys: string[], eventKey: string) =>
pathKeys.some(pathKey => {
(pathKeys: string[], eventKey: string) => {
if (pathKeys.every(key => key === undefined)) {
return false;
}
return pathKeys.some(pathKey => {
const pathKeyList = getKeyPath(pathKey, true);

return pathKeyList.includes(eventKey);
}),
});
},
[getKeyPath],
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isSubPathKey = useCallback(
(pathKeys: string[], eventKey: string) =>
pathKeys.some(pathKey => {
(pathKeys: string[], eventKey: string) => {
if (pathKeys.every(key => key === undefined)) {
return false;
}
return pathKeys.some(pathKey => {
const pathKeyList = getKeyPath(pathKey, true);
return pathKeyList.includes(eventKey);
}),
});
},
[getKeyPath],
);
const isSubPathKey = useCallback(
(pathKeys: string[], eventKey: string) =>
pathKeys.filter(item => item !== undefined).some(pathKey => {
const pathKeyList = getKeyPath(pathKey, true);
return pathKeyList.includes(eventKey);
}),
[getKeyPath],
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样是不更简单点?


const getKeys = () => {
const keys = [...key2pathRef.current.keys()];

Expand Down
Loading