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

Conversation

coderz-w
Copy link
Contributor

@coderz-w coderz-w commented Jun 10, 2024

Comment on lines 75 to 87
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.

这样是不更简单点?

@afc163
Copy link
Member

afc163 commented Jun 10, 2024

需要补充用例。

@coderz-w
Copy link
Contributor Author

需要补充用例。

好,佬之前那个看一下react-component/upload#559

tests/SubMenu.spec.tsx Outdated Show resolved Hide resolved
tests/SubMenu.spec.tsx Outdated Show resolved Hide resolved
tests/SubMenu.spec.tsx Fixed Show resolved Hide resolved
@afc163 afc163 merged commit 526a924 into react-component:master Jun 20, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants