Skip to content

Commit

Permalink
fix(layout): menuItem support disableTooltip
Browse files Browse the repository at this point in the history
close #6460
  • Loading branch information
chenshuai2144 committed Jul 15, 2023
1 parent 189f933 commit 84b79c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/layout/src/components/SiderMenu/BaseMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const MenuItemTooltip = (props: {
collapsed?: boolean;
children: React.ReactNode;
title?: React.ReactNode;
disable?: boolean;
}) => {
const [collapsed, setCollapsed] = useState(props.collapsed);
const [open, setOpen] = useState(false);
Expand All @@ -41,6 +42,10 @@ const MenuItemTooltip = (props: {
}, 400);
}, [props.collapsed]);

if (props.disable) {
return props.children as JSX.Element;
}

return (
<Tooltip
title={props.title}
Expand Down Expand Up @@ -363,7 +368,11 @@ class MenuUtil {
);
const defaultIcon = collapsed && hasIcon ? getMenuTitleSymbol(name) : null;
let defaultItem = (
<MenuItemTooltip collapsed={collapsed} title={name}>
<MenuItemTooltip
collapsed={collapsed}
title={name}
disable={item.disabledTooltip}
>
<div
key={itemPath}
className={classNames(
Expand Down
2 changes: 2 additions & 0 deletions packages/layout/src/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export type MenuDataItem = {
key?: string;
/** @name disable 菜单选项 */
disabled?: boolean;
/** @name disable menu 的 tooltip 菜单选项 */
disabledTooltip: boolean;
/** @name 路径,可以设定为网页链接 */
path?: string;
/**
Expand Down

0 comments on commit 84b79c8

Please sign in to comment.