@@ -40,6 +40,14 @@ const ANIMATION_CLASSES =
4040const MENU_ROW_HEIGHT_CLASS = 'h-[28px]'
4141const MENU_ROW_RADIUS_CLASS = 'rounded-lg'
4242
43+ /**
44+ * Rows are a fixed height, so a label that wraps overflows its row and paints
45+ * over its neighbours instead of growing the row. Keep every row on one line:
46+ * a bare text label is clipped at the surface edge, and a label wrapped in a
47+ * `<span>` (the shape long or count-bearing labels should use) ellipsizes.
48+ */
49+ const MENU_ROW_SINGLE_LINE_CLASS = 'whitespace-nowrap [&>span]:min-w-0 [&>span]:truncate'
50+
4351/**
4452 * Surface corner, shared by the root menu and submenus — they previously
4553 * disagreed, at 12px and 8px.
@@ -110,7 +118,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
110118 < DropdownMenuPrimitive . SubTrigger
111119 ref = { ref }
112120 className = { cn (
113- `flex ${ MENU_ROW_HEIGHT_CLASS } min-w-0 cursor-default select-none items-center gap-2 ${ MENU_ROW_RADIUS_CLASS } px-2 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[state=open]:bg-[var(--surface-active)] [&>span]:min-w-0 [&>span]:truncate [&_svg]:pointer-events-none [&_svg]:size-[14px] [&_svg]:shrink-0 [&_svg]:text-[var(--text-icon)]` ,
121+ `flex ${ MENU_ROW_HEIGHT_CLASS } min-w-0 cursor-default select-none items-center gap-2 ${ MENU_ROW_RADIUS_CLASS } px-2 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[state=open]:bg-[var(--surface-active)] ${ MENU_ROW_SINGLE_LINE_CLASS } [&_svg]:pointer-events-none [&_svg]:size-[14px] [&_svg]:shrink-0 [&_svg]:text-[var(--text-icon)]` ,
114122 inset && 'pl-7' ,
115123 className
116124 ) }
@@ -172,7 +180,7 @@ const DropdownMenuContent = React.forwardRef<
172180) )
173181DropdownMenuContent . displayName = DropdownMenuPrimitive . Content . displayName
174182
175- const DROPDOWN_MENU_ITEM_BASE_CLASSES = `relative flex ${ MENU_ROW_HEIGHT_CLASS } min-w-0 cursor-pointer select-none items-center gap-2 ${ MENU_ROW_RADIUS_CLASS } px-2 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:min-w-0 [&>span]:truncate [&_svg]:pointer-events-none [&_svg]:size-[14px] [&_svg]:shrink-0 [&_svg]:text-[var(--text-icon)]`
183+ const DROPDOWN_MENU_ITEM_BASE_CLASSES = `relative flex ${ MENU_ROW_HEIGHT_CLASS } min-w-0 cursor-pointer select-none items-center gap-2 ${ MENU_ROW_RADIUS_CLASS } px-2 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 ${ MENU_ROW_SINGLE_LINE_CLASS } [&_svg]:pointer-events-none [&_svg]:size-[14px] [&_svg]:shrink-0 [&_svg]:text-[var(--text-icon)]`
176184
177185const DropdownMenuItem = React . forwardRef <
178186 React . ElementRef < typeof DropdownMenuPrimitive . Item > ,
@@ -252,7 +260,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
252260 < DropdownMenuPrimitive . CheckboxItem
253261 ref = { ref }
254262 className = { cn (
255- `relative flex ${ MENU_ROW_HEIGHT_CLASS } cursor-default select-none items-center ${ MENU_ROW_RADIUS_CLASS } pr-2 pl-7 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50` ,
263+ `relative flex ${ MENU_ROW_HEIGHT_CLASS } cursor-default select-none items-center ${ MENU_ROW_RADIUS_CLASS } whitespace-nowrap pr-2 pl-7 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50` ,
256264 className
257265 ) }
258266 checked = { checked }
@@ -275,7 +283,7 @@ const DropdownMenuRadioItem = React.forwardRef<
275283 < DropdownMenuPrimitive . RadioItem
276284 ref = { ref }
277285 className = { cn (
278- `relative flex ${ MENU_ROW_HEIGHT_CLASS } cursor-default select-none items-center ${ MENU_ROW_RADIUS_CLASS } pr-2 pl-7 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50` ,
286+ `relative flex ${ MENU_ROW_HEIGHT_CLASS } cursor-default select-none items-center ${ MENU_ROW_RADIUS_CLASS } whitespace-nowrap pr-2 pl-7 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50` ,
279287 className
280288 ) }
281289 { ...props }
0 commit comments