From e8963cc28a7434ac8476e3d8321a9a74101a8ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9F=E8=B4=A4?= Date: Sun, 12 Mar 2023 19:33:42 +0800 Subject: [PATCH] fix(layout): fix sider menu height --- .../src/components/SiderMenu/SiderMenu.tsx | 8 ++-- .../src/components/SiderMenu/style/index.ts | 1 + .../src/components/SiderMenu/style/menu.ts | 4 +- tests/form/__snapshots__/demo.test.ts.snap | 4 +- tests/form/lightFilter.test.tsx | 44 ++++++++++++++----- tests/layout/__snapshots__/demo.test.ts.snap | 12 ++--- 6 files changed, 47 insertions(+), 26 deletions(-) diff --git a/packages/layout/src/components/SiderMenu/SiderMenu.tsx b/packages/layout/src/components/SiderMenu/SiderMenu.tsx index a8fd93f03465..3d15a5d4786d 100644 --- a/packages/layout/src/components/SiderMenu/SiderMenu.tsx +++ b/packages/layout/src/components/SiderMenu/SiderMenu.tsx @@ -205,10 +205,13 @@ const SiderMenu: React.FC = (props) => { const baseClassName = `${prefixCls}-sider`; + // 收起的宽度 + const collapsedWidth = 64; + // 之所以这样写是为了提升样式优先级,不然会被sider 自带的覆盖掉 const stylishClassName = useStylish(`${baseClassName}.${baseClassName}-stylish`, { stylish, - proLayoutCollapsedWidth: 64, + proLayoutCollapsedWidth: collapsedWidth, }); const siderClassName = classNames(`${baseClassName}`, hashId, { @@ -338,8 +341,6 @@ const SiderMenu: React.FC = (props) => { ); }, [actionsDom, avatarDom, baseClassName, collapsed, hashId]); - const collapsedWidth = 60; - /* Using the useMemo hook to create a CSS class that will hide the menu when the menu is collapsed. */ const hideMenuWhenCollapsedClassName = useMemo(() => { // 收起时完全隐藏菜单 @@ -474,7 +475,6 @@ const SiderMenu: React.FC = (props) => { colorActiveBarWidth: 0, colorActiveBarHeight: 0, colorActiveBarBorderSize: 0, - controlHeightLG: 35, colorItemText: token?.layout?.sider?.colorTextMenu || 'rgba(0, 0, 0, 0.65)', colorItemTextHover: token?.layout?.sider?.colorTextMenuActive || 'rgba(0, 0, 0, 0.85)', diff --git a/packages/layout/src/components/SiderMenu/style/index.ts b/packages/layout/src/components/SiderMenu/style/index.ts index a6aae1e0a756..6815f3ffff54 100644 --- a/packages/layout/src/components/SiderMenu/style/index.ts +++ b/packages/layout/src/components/SiderMenu/style/index.ts @@ -46,6 +46,7 @@ const genSiderMenuStyle: GenerateStyle = (token) => { paddingInline: token.layout?.sider?.paddingInlineLayoutMenu, paddingBlock: token.layout?.sider?.paddingBlockLayoutMenu, borderInlineEnd: `1px solid ${token.colorSplit}`, + marginInlineEnd: -1, }, [`${token.antCls}-menu`]: { [`${token.antCls}-menu-item-group-title`]: { diff --git a/packages/layout/src/components/SiderMenu/style/menu.ts b/packages/layout/src/components/SiderMenu/style/menu.ts index df89037bb416..cee52983e16b 100644 --- a/packages/layout/src/components/SiderMenu/style/menu.ts +++ b/packages/layout/src/components/SiderMenu/style/menu.ts @@ -61,8 +61,8 @@ const genProLayoutBaseMenuStyle: GenerateStyle = (token) '&-collapsed': { flexDirection: 'column', justifyContent: 'center', - width: 35, - height: 35, + minWidth: 40, + height: 40, [`${token.componentCls}-item-icon`]: { height: '16px', width: '16px', diff --git a/tests/form/__snapshots__/demo.test.ts.snap b/tests/form/__snapshots__/demo.test.ts.snap index ec3ea63f9a84..f94bfdee1f17 100644 --- a/tests/form/__snapshots__/demo.test.ts.snap +++ b/tests/form/__snapshots__/demo.test.ts.snap @@ -45403,11 +45403,11 @@ exports[`form demos 📸 renders ./packages/form/src/demos/layout-footer.tsx cor style="min-height: 100%; flex-direction: row;" >