Skip to content

fix(ListItemView): give the public CSS variables priority over modifiers - #2969

Open
amje wants to merge 3 commits into
mainfrom
fix/list-item-view-css-vars
Open

amje wants to merge 3 commits into
mainfrom
fix/list-item-view-css-vars

Conversation

@amje

@amje amje commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What

The modifiers of ListItemView wrote literal values into the private --_--* variables that also carried the public --g-list-item-view-* ones. _is-container set --_--padding-*: 0, so the paddings MenuItem sets through --g-list-item-view-padding-* were ignored and menu items lost their paddings.

The styles now follow the pattern of Button:

  • private --_--* variables hold plain defaults, and modifiers (_size_*, _is-container, _active, _selected, _disabled) change only them;
  • public --g-list-item-view-* variables are resolved where a value is used: padding-inline: var(--g-list-item-view-padding-inline, var(--_--padding-inline)).

Menu

  • MenuItem drops its own padding and sets the public padding variables per size; display: flex is scoped with .g-list-item-view so it wins over _is-container.
  • A disabled item is gray whatever its theme: the theme text colour no longer applies to an item with aria-disabled.
  • A wrapped item title starts at the edge instead of being centred like the text of a button (text-align: start).

Behaviour changes

  • A row with isContainer has no paddings by default, but the padding variables now apply to it (documented in the README).
  • On a disabled row --g-list-item-view-description-color takes priority over the text colour.
  • Background states: :hover / _hovered_yes use --g-list-item-view-background-color-hover, other states use --g-list-item-view-background-color. A selected row with _hovered_yes now shows the selection hover colour; with the public variables set, a hovered active row uses the hover variable and a selected active row uses the background variable.
  • Disabled Menu items with the info, success, warning, danger or utility theme are gray instead of the theme colour.

Tests

New visual tests for Menu (22 in total, 28 snapshots, light and dark themes): item paddings and heights per size, sizes with icons, hotkeys, a divider and disabled items, all themes (also disabled), selection, alignment of items without an icon or an arrow and of a wrapped title, links, hover on a plain and a selected item, keyboard navigation, the popup and a submenu opened on hover.

Testing

  • npm run lint:styles, npm run typecheck, ESLint on the tests, prettier — clean.
  • Playwright in Docker for ListItemView, Menu, List, Select, Breadcrumbs, HelloPangeaDnd, ActionsPanel, legacy Table, TabList: no changes to existing snapshots. The new Menu tests pass 3 runs in a row (--repeat-each=3). legacy/Table "smoke with table settings" was flaky in the local working tree only (anti-aliasing of the Apply button text); on a clean checkout with this change it passed 10/10.

🤖 Generated with Claude Code

Private --_--* variables now hold plain defaults that modifiers change, and the
public --g-list-item-view-* variables are resolved where a value is used. The
isContainer modifier no longer zeroes paddings set through the CSS API, so
MenuItem sets its paddings with --g-list-item-view-padding-* again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gravity-ui

gravity-ui Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Preview is ready.

@gravity-ui

gravity-ui Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

🎭 Component Tests Report is ready.

amje and others added 2 commits December 4, 2026 18:04
…the edge

The theme text colour no longer applies to a disabled item, so it gets the
colour of a disabled row. A title that wraps starts at the edge instead of
being centred like the text of a button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Visual tests for the sizes and paddings of items, the themes (also disabled),
selection, alignment of items without an icon or an arrow, links, hover,
keyboard navigation, the popup and a submenu, in the light and dark themes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@media (hover: hover) {
&:not(&_hovered_no):hover {
--_--background-color: var(--_--background-color-hover);
background: var(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI generated

❓ question — A disabled row suppresses its hover only through the private --_--background-color-hover: transparent (lines 267–270). :hover (224–227) and _hovered_yes (231–236) read the public --g-list-item-view-background-color-hover first, so when the variable is set, a disabled row under the pointer is highlighted.

This is reachable in Select. SelectList.scss:41–43 gives disabled options pointer-events: auto again, and the Select README and the v8 migration guides recommend setting --g-list-item-view-* on popupClassName. A hovered disabled option stays transparent without the variable and is highlighted with it.

Is that intended? If not, exclude disabled rows from the hover rules: &:not(&_hovered_no, &_disabled):hover and &_hovered_yes:not(&_disabled). Then --_--background-color-hover: transparent at line 269 is no longer needed.

content: '';
}

// A disabled item has the colour of a disabled row, whatever its theme

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI generated

❓ question — A disabled item is now gray, but its trailing slot is not. In the new render size * snapshots, the Ctrl X hotkey of the disabled "Cut" keeps full contrast next to a gray icon and title. Neither part of the slot follows the disabled colour of the row:

  • __arrow has its own color: var(--g-color-text-secondary) (line 35), so the submenu chevron of a disabled item stays secondary too;
  • Hotkey sets its own text and background colours.

Is that intended? If not, dim the arrow slot of a disabled item as well, e.g. through &[aria-disabled='true'] &__arrow.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants