Skip to content

Commit a96e441

Browse files
committed
Use different MenuItem props for plain text and rich text labels
1 parent 9b0a025 commit a96e441

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/sidebar/components/GroupList/GroupListItem.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ function GroupListItem({
127127
isExpanded={hasActionMenu ? isExpanded : false}
128128
isSelected={isSelected}
129129
isSubmenuVisible={hasActionMenu ? isExpanded : undefined}
130-
label={
130+
label={group.name}
131+
richLabel={
131132
<div className="grow flex items-center justify-between gap-x-2">
132133
{group.name}
133134
<GroupIcon type={group.type} />

src/sidebar/components/MenuItem.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,17 @@ export type MenuItemProps = {
101101
*/
102102
isSubmenuVisible?: boolean;
103103

104-
label: ComponentChildren;
104+
/**
105+
* Main text of the menu item.
106+
* This is also used as part of the submenu toggle's title, if any.
107+
*/
108+
label: string;
109+
110+
/**
111+
* An alternative to `label`, in case you need to render more complex/rich
112+
* content in this item.
113+
*/
114+
richLabel?: ComponentChildren;
105115

106116
/**
107117
* Optional content to render into a left channel. This accommodates small
@@ -146,6 +156,7 @@ export default function MenuItem({
146156
isSubmenuItem,
147157
isSubmenuVisible,
148158
label,
159+
richLabel = label,
149160
leftChannelContent,
150161
onClick,
151162
onToggleSubmenu,
@@ -214,7 +225,7 @@ export default function MenuItem({
214225
</div>
215226
)}
216227
<span className="flex items-center grow whitespace-nowrap px-1">
217-
{label}
228+
{richLabel}
218229
</span>
219230
{hasRightContent && (
220231
<div

0 commit comments

Comments
 (0)