Skip to content

Commit f7175fe

Browse files
committed
add tooltip property to MenuItem
1 parent 14aef37 commit f7175fe

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2727
- `noWrap` property to display them without wrapping its children on multiple lines
2828
- `<SimpleDialog />`
2929
- `actionsProps` property to forward `CardActions` properties, e.g. `noWrap`
30+
- `<MenutItem />`
31+
- `tooltip` property to dislay tooltip on menu item label
3032

3133
## [24.0.1] - 2025-02-06
3234

src/components/Menu/MenuItem.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { openInNewTab } from "../../common/utils/openInNewTab";
55
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
66
import { ValidIconName } from "../Icon/canonicalIconNames";
77
import Icon from "../Icon/Icon";
8+
import Tooltip from "../Tooltip/Tooltip";
89

910
import { TestIconProps } from "./../Icon/TestIcon";
1011

@@ -15,16 +16,41 @@ export interface MenuItemProps
1516
* If set the icon is diplayed on the left side of the menu item.
1617
*/
1718
icon?: ValidIconName | string[] | React.ReactElement<TestIconProps>;
19+
/**
20+
* Submenu.
21+
*/
1822
children?: React.ReactNode;
23+
/**
24+
* Tooltip, but only added to the label, not to the full menu item.
25+
*/
26+
tooltip?: React.ReactNode;
1927
}
2028

2129
/**
2230
* Single item, used as child inside `Menu`.
2331
*/
24-
export const MenuItem = ({ children, className = "", icon, onClick, href, ...restProps }: MenuItemProps) => {
32+
export const MenuItem = ({
33+
children,
34+
className = "",
35+
icon,
36+
onClick,
37+
href,
38+
text,
39+
tooltip,
40+
...restProps
41+
}: MenuItemProps) => {
2542
return (
2643
<BlueprintMenuItem
2744
{...restProps}
45+
text={
46+
tooltip ? (
47+
<Tooltip content={tooltip} fill>
48+
{text}
49+
</Tooltip>
50+
) : (
51+
text
52+
)
53+
}
2854
href={href}
2955
onClick={(e: React.MouseEvent<HTMLElement>) =>
3056
openInNewTab(e as React.MouseEvent<HTMLAnchorElement>, onClick, href)

0 commit comments

Comments
 (0)