New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add <Menu.Item>content</Menu.item>
syntax
#9242
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should deprecate primaryText
to remove it in v5 IMO
<Menu.Item>title</Menu.item>
syntax<Menu.Item>content</Menu.item>
syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fzaninotto You're right. However, I don't understand why you are saying "we have to render both in the expanded menu for backwards compatibility reasons". Unless I'm mistaken, The following seems to work according to my tests: const renderMenuItem = () => {
return (
<StyledMenuItem
className={clsx(className, {
[MenuItemLinkClasses.active]: !!match,
})}
// @ts-ignore
component={LinkRef}
ref={ref}
tabIndex={0}
{...rest}
onClick={handleMenuTap}
>
{leftIcon && (
<ListItemIcon className={MenuItemLinkClasses.icon}>
{leftIcon}
</ListItemIcon>
)}
{children
? children
: typeof primaryText === 'string'
? translate(primaryText, { _: primaryText })
: primaryText}
</StyledMenuItem>
);
};
return open ? (
renderMenuItem()
) : (
<Tooltip
title={
typeof primaryText === 'string'
? translate(primaryText, { _: primaryText })
: null
}
placement="right"
{...tooltipProps}
>
{renderMenuItem()}
</Tooltip>
); |
You're right, it works! I've pushed the changes. Switching back to RFR. |
</ListItemIcon> | ||
<ListItemText>Customers</ListItemText> | ||
</Menu.Item> | ||
<Tooltip title="Catalog" placement="right"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this Tooltip
displays all the time, not only when the side menu is collapsed. Not sure it's worth it to bother fixing it though, it's really minor...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw it. This is indeed minor, and it's on an internal story, so I though we could live with it.
Co-authored-by: Jean-Baptiste Kaiser <jb@marmelab.com>
Problem
The
<Menu.Item primaryText>
syntax isn't intuitive, especially for someone who already knows material-ui, where the menu label is expressed viachildren
.Solution
Support menu label is expressed via
children
in addition toprimaryText
for mobileThe following is still supported: