Skip to content

Commit ed9be7b

Browse files
committed
refactor: improve handling of empty search results in Help component
- Updated the `Highlight` component to return a wrapper with a title when no keywords are provided, enhancing user experience for empty search results. - Adjusted the `ProHelpSelect` component to conditionally pass keywords, ensuring consistent behavior when no search term is present.
1 parent 194b819 commit ed9be7b

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/layout/components/SiderMenu/BaseMenu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,15 +644,16 @@ const BaseMenu: React.FC<BaseMenuProps & PrivateSiderMenuProps> = (props) => {
644644
);
645645
}
646646
setOpenKeys(newKeys);
647-
} else if (menu?.ignoreFlatMenu && defaultOpenAll) {
647+
} else if (menu?.ignoreFlatMenu && defaultOpenAll && !props.collapsed) {
648648
// 忽略用户手动折叠过的菜单状态,折叠按钮切换之后也可实现默认展开所有菜单
649+
// 但是如果用户手动点击关闭菜单,则应该遵循用户的选择
649650
setOpenKeys(getOpenKeysFromMenuData(menuData));
650651
} else {
651652
setDefaultOpenAll(false);
652653
}
653654
},
654655
// eslint-disable-next-line react-hooks/exhaustive-deps
655-
[matchMenuKeys.join('-')],
656+
[matchMenuKeys.join('-'), props.collapsed],
656657
);
657658

658659
const openKeysProps = useMemo(

tests/layout/__snapshots__/pageHeaderWarp.test.tsx.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3+
exports[`BasicLayout > ActionsContent support contentRender 1`] = `
4+
<div>
5+
<div
6+
class="ant-pro-global-header-right-content"
7+
style="min-width: auto; height: 100%;"
8+
>
9+
<div
10+
style="height: 100%;"
11+
/>
12+
</div>
13+
</div>
14+
`;
15+
316
exports[`BasicLayout > base use 1`] = `
417
<div>
518
<div

tests/layout/pageHeaderWarp.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PageContainer, ProLayout } from '@ant-design/pro-components';
22
import { cleanup, render } from '@testing-library/react';
3-
import { ActionsContent } from 'src/layout/components/GlobalHeader/ActionsContent';
43
import { afterEach, describe, expect, it } from 'vitest';
4+
import { ActionsContent } from '../../src/layout/components/GlobalHeader/ActionsContent';
55
import defaultProps from './defaultProps';
66

77
afterEach(() => {

0 commit comments

Comments
 (0)