From b78487cd725532000f81876e1826f1918c37b23a Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Mon, 6 Nov 2023 14:35:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(menu):=20=E4=BF=AE=E5=A4=8D=20mini=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=AD=90=E8=8F=9C=E5=8D=95=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E5=B1=95=E7=A4=BA=E4=B8=8D=E5=85=A8=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#2656)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/thick-news-joke.md | 5 +++++ .changeset/wet-snails-cover.md | 5 +++++ packages/ui/menu/src/Menu.tsx | 24 +++++++++++++++--------- packages/ui/menu/src/MenuItem.tsx | 8 ++++---- 4 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 .changeset/thick-news-joke.md create mode 100644 .changeset/wet-snails-cover.md diff --git a/.changeset/thick-news-joke.md b/.changeset/thick-news-joke.md new file mode 100644 index 000000000..7e664397d --- /dev/null +++ b/.changeset/thick-news-joke.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +Menu fix: 修复 mini 模式下子菜单内容展示不全问题 diff --git a/.changeset/wet-snails-cover.md b/.changeset/wet-snails-cover.md new file mode 100644 index 000000000..b5bcd47bb --- /dev/null +++ b/.changeset/wet-snails-cover.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/menu": patch +--- + +fix: 修复 mini 模式下子菜单内容展示不全问题 diff --git a/packages/ui/menu/src/Menu.tsx b/packages/ui/menu/src/Menu.tsx index 50bbf7aea..586790d15 100644 --- a/packages/ui/menu/src/Menu.tsx +++ b/packages/ui/menu/src/Menu.tsx @@ -227,6 +227,18 @@ export const Menu = forwardRef( ) } + const renderItem = useCallback( + (menuItem: MenuDataItem, level?: number) => { + // 显示缩略内容 + if (showMini && level === 1) { + return renderMenuItemMini(menuItem) + } + + return isFunction(render) ? render(menuItem, level) : menuItem.title + }, + [render, showMini] + ) + const cls = cx( prefixCls, className, @@ -260,19 +272,13 @@ export const Menu = forwardRef( {mergedTagList.map((item, index) => { return showMini ? ( - + ) : (