Skip to content

Dropdown: children in the trigger, a select's chevron, per-menu classes - #354

Merged
samitbasu merged 2 commits into
mainfrom
dd-325
Nov 18, 2026
Merged

samitbasu merged 2 commits into
mainfrom
dd-325

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Fixes #325: items 1 and 5 of the design note. Items 2, 3 and 4 are in #342, and item 6 is in #344.

What changes

  • DropdownChain::children(body): builds body inside the trigger, after its icon and label, as ButtonChain::children does. With Face::Empty(name) the trigger is the children alone (a swatch, say), named by name.
  • DropdownChain::chevron(): a down chevron after the trigger's content (after the children, if any), the same one the select draws. It reads the select's own tokens, so the two always match across Vega, Lyra and the sizes, and it adds no style field:
    • size: select.chevron
    • tone: select.chevron_opacity over the trigger's text colour
    • gap: the trigger's own gap
    • It doesn't turn while the menu is open, as the select's doesn't. It is decorative: the trigger's accessible name is unchanged.
  • DropdownChain::menu_classes(tw): classes merged over this dropdown's menu box only, such as min_w_px or max_h. Submenus and other menus keep the style's.
  • The menu example: Actions ends in a chevron, and a new Accent dropdown has a swatch trigger (children with Face::Empty), a chevron, and a 200 px menu (menu_classes).

Nothing breaks: all three are additions.

Decisions

Picked by the user:

  • Q1.3, the chevron's look: the candidates' A16 + B8 + C1 + D1, which looks exactly like the select. It is implemented by reading the select's tokens, with no new style fields. "It suggests the same thing in both cases."
  • Q5.1: menu_classes(tw) rather than min_width(..).

Decided by default, for review:

  • Q1.1: .chevron() is the stock down chevron only, not a general trailing icon on every button.
  • Q1.2: the chevron is decorative and stays out of the accessible name.
  • Q5.2: context menus don't take menu_classes yet.
  • New, not in the note: the chevron follows the children when there are both.
  • New, not in the note: the menu example gained the Accent dropdown, using Tailwind's blue, green and rose 500 swatches.

Changed goldens

Actions' chevron and the new Accent trigger appear in the top row:

  • tests/snapshots/menu_open_light.png
  • tests/snapshots/menu_open_dark.png
  • tests/snapshots/menu_destructive_light.png
  • tests/snapshots/menu_destructive_dark.png
  • tests/snapshots/menu_list_open_light.png
  • tests/snapshots/menu_list_open_dark.png (the list covers the top row; the new trigger shows beside it)

Main, with #342 and #344 merged, is merged into this branch; the first four were regenerated over #342's, so they show Show grid's Ctrl+Alt+G too.

Tests

New in tests/it/menu.rs, mod trigger, through the real path:

  • a_chevron_trails_the_label_at_the_triggers_gap_and_is_as_big_as_a_selects: the gap after the label is the trigger's own gap, measured from an icon trigger, and the chevron is the select's size. The trigger is still named by its label.
  • the_chevron_takes_the_selects_size_and_tone_from_the_style: with select.chevron set to 20, both the dropdown's chevron and the select's are 20 px. At a quarter chevron_opacity the chevron draws at under half the alpha of full opacity.
  • a_trigger_has_no_chevron_unless_asked
  • children_fill_a_trigger_whose_face_is_empty_and_it_is_named_by_the_face: the child is inside the trigger and before the chevron, and the trigger, named by the face, opens its menu.
  • menu_classes_reach_that_menus_box_alone: 300 px for that menu, the style's width for its sibling.

Reversion check: on main the suite does not compile (the API is new). Each mutation below fails its tests, and the unmutated branch passes all five:

  • chevron never drawn: 3 fail;
  • a fixed 16 px chevron: 1 fails;
  • the tone ignored: 1 fails;
  • children dropped: 1 fails;
  • menu classes dropped: 1 fails;
  • the chevron drawn before the children: 1 fails.

TODO(prose)

DropdownChain::children, DropdownChain::chevron, DropdownChain::menu_classes.

Manual trial

The menu example (examples/menu.rs):

  • Actions ends in a chevron like a select's.
  • Accent's trigger is a swatch of the chosen colour and a chevron. Its menu is wider than Actions', and choosing a colour changes the swatch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o

samitbasu and others added 2 commits November 17, 2026 20:29
Fixes #325 (items 1 and 5).

A dropdown trigger could only hold a label and a leading icon, had no
trailing chevron, and every menu took the style's width.

- DropdownChain::children builds content inside the trigger, as
  ButtonChain::children does; with Face::Empty the trigger is the children
  alone, named by the face.
- DropdownChain::chevron draws the select's down chevron after the
  content, at the select's size (select.chevron) and tone
  (select.chevron_opacity) and the trigger's own gap, so the two match
  across styles and sizes. No style field is added.
- DropdownChain::menu_classes merges classes over that menu's box alone.
- The menu example: Actions ends in a chevron; an Accent dropdown shows a
  swatch trigger, a chevron and a wider menu.

Behaviour change: the menu example's top row has the chevron and the
Accent trigger; six menu goldens change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
# Conflicts:
#	tests/it/menu.rs
#	tests/snapshots/menu_destructive_dark.png
#	tests/snapshots/menu_destructive_light.png
#	tests/snapshots/menu_open_dark.png
#	tests/snapshots/menu_open_light.png
@samitbasu

Copy link
Copy Markdown
Owner Author

Approved by the user (2026-11-18). Gate (my run with current main): cargo xtask ci exits 0. Merging.

@samitbasu
samitbasu merged commit c13272b into main Nov 18, 2026
4 checks passed
samitbasu added a commit that referenced this pull request Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
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.

Menus and commands: trigger content, command items as chains, checked command items, run_with, per-menu width

1 participant