DropdownMenu disabled item icon color + not-allowed cursor (WEB-1190)
Version: 0.7.0 ยท Type: ๐ Bug Fix
Problemโ
- Icon color: When a DropdownMenu item is
disabled, the label text turnsLabels/Disabledviadata-disabled:text-(--Labels-Disabled), but the leading icon container declares its own color explicitly (Labels/Primaryfor default,Labels/Errorfor danger) and therefore does not dim, leaving a disabled item with grey text but a full-color icon. Cascading submenu (SubTrigger) leading icons and the trailing arrow had the same problem. - Cursor: The ui layer applies
data-disabled:pointer-events-none, which suppressed the design layer'scursor-*, so a disabled item never showedcursor-not-allowedon hover.
Changed Filesโ
packages/design/src/components/DropdownMenu/styles.tspackages/design/src/components/DropdownMenu/DropdownMenu.tsxpackages/design/src/components/DropdownMenu/DropdownMenuDesignSpec.mdpackages/design/src/components/DropdownMenu/__tests__/DropdownMenu.test.tsx
Changesโ
- Added a shared class
DROPDOWN_ICON_DISABLED_COLOR_CLASS = '[[data-disabled]_&]:text-(--Labels-Disabled)'. It uses an ancestor[data-disabled]selector so the icon container overrides toLabels/Disabledwhenever its parent item is disabled (the icon container declares its color explicitly and does not inherit the item's disabled text color). getDropdownMenuItemIconColorClassnow appends the disabled class on top of the variant color (defaultLabels/Primary/ dangerLabels/Error), coveringDropdownMenuItem's leading icon.DropdownMenuSubTrigger's leading icon container gets the same disabled class;DROPDOWN_SUB_ARROW_COLOR_CLASS(trailing cascade arrow) appends it on top ofGrays/Gray-4, so a disabled submenu item dims entirely.- Added
data-disabled:pointer-events-auto+data-disabled:cursor-not-allowedtoDROPDOWN_ITEM_BASE_CLASS(shared by Item and SubTrigger), overriding the ui layer'spointer-events-noneso disabled items show the not-allowed cursor (mirrors the existing Button approach). Selection is still blocked by Radix's internal disabled guard, and since the base only usesfocus/data-highlighted(nothover), disabled items never get a hover background. - Unit test: a disabled item asserts its leading icon container carries
[[data-disabled]_&]:text-(--Labels-Disabled), and the menu item carriesdata-disabled:pointer-events-auto/data-disabled:cursor-not-allowed.