Skip to content

Commit

Permalink
fix(layout): fix layout menu align error
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Oct 23, 2023
1 parent 478c333 commit 24cf799
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/layout/src/ProLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,9 @@ const BaseProLayout: React.FC<ProLayoutProps> = (props) => {
* 使用number是因为多标签页的时候有多个 PageContainer,只有有任意一个就应该展示这个className
*/
const [hasPageContainer, setHasPageContainer] = useState(0);

useDocumentTitle(pageTitleInfo, props.title || false);

const bgImgStyleList = useMemo(() => {
if (bgLayoutImgList && bgLayoutImgList.length > 0) {
return bgLayoutImgList.map((item, index) => {
Expand Down Expand Up @@ -789,7 +791,7 @@ const BaseProLayout: React.FC<ProLayoutProps> = (props) => {
token.layout?.sider?.colorMenuBackground || 'transparent',
colorSubItemBg:
token.layout?.sider?.colorMenuBackground || 'transparent',
radiusItem: 4,
radiusItem: token.borderRadius,
controlHeightLG:
token.layout?.sider?.menuHeight || token?.controlHeightLG,
colorItemBgSelected:
Expand Down
2 changes: 1 addition & 1 deletion packages/layout/src/components/Help/ProHelpPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export const ProHelpPanel: React.FC<ProHelpPanelProps> = ({
lineHeight: 1.2,
controlHeightLG: 26,
fontSize: 12,
radiusItem: 4,
radiusItem: token.borderRadius,
colorActiveBarWidth: 0,
colorActiveBarBorderSize: 0,
colorItemBgSelected:
Expand Down
7 changes: 5 additions & 2 deletions packages/layout/src/components/SiderMenu/BaseMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ class MenuUtil {
? subMenuItemRender({ ...item, isUrl: false }, defaultTitle, this.props)
: defaultTitle;

const childrenList = this.getNavMenuItems(children, level + 1);

// 如果收起来,没有子菜单了,就不需要展示 group,所以 level 不增加
if (
isGroup &&
Expand All @@ -289,6 +287,11 @@ class MenuUtil {
return this.getNavMenuItems(children, level);
}

const childrenList = this.getNavMenuItems(
children,
isGroup && level === 0 ? level : level + 1,
);

return [
{
type: menuType,
Expand Down
3 changes: 2 additions & 1 deletion packages/layout/src/components/TopNavHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const TopNavHeader: React.FC<TopNavHeaderProps> = (
token.layout?.header?.colorBgHeader || 'transparent',
colorSubItemBg:
token.layout?.header?.colorBgHeader || 'transparent',
radiusItem: 4,
radiusItem: token.borderRadius,
colorItemBgSelected:
token.layout?.header?.colorBgMenuItemSelected ||
token?.colorBgTextHover,
Expand Down Expand Up @@ -139,6 +139,7 @@ const TopNavHeader: React.FC<TopNavHeaderProps> = (
token.layout?.header?.colorTextMenuActive,
token.layout?.header?.colorTextMenuSelected,
token.layout?.header?.colorBgMenuElevated,
token.borderRadius,
token?.colorBgTextHover,
token?.colorTextSecondary,
token?.colorText,
Expand Down
2 changes: 1 addition & 1 deletion tests/layout/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ describe('BasicLayout', () => {
await waitForWaitTime(100);
expect(
wrapper.baseElement.querySelectorAll('.ant-menu-item-group-title').length,
).toBe(2);
).toBe(3);
expect(
wrapper.baseElement.querySelectorAll('.ant-pro-sider-actions-collapsed')
.length,
Expand Down

0 comments on commit 24cf799

Please sign in to comment.