You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Menus and commands: trigger content, command items as chains, checked command items, run_with, per-menu width #325
Gaps found by a consumer moving onto v0.1.0-m8.26:
A dropdown trigger can't hold custom content or a trailing icon.DropdownChain has a leading icon only. The consumer paints glyphs and a chevron over plain triggers (~70 lines). Proposal: DropdownChain::children(..) as on ButtonChain, and/or .trailing_icon(..) / .chevron().
No check or radio item bound to a command.Menu::command always builds a plain item, and Commands::find is pub(crate), so the app can't read a command's chord. Proposal: m.command(id).checked(Mark), and a public chord read.
Menu::command returns (). A command item can't be .inset(), .icon(), .destructive() or .focus_on_open(), so command items don't line up with marked ones. Proposal: return the ItemChain pre-filled with title, shortcut and enablement, finished with .add().
A command's run/enabled are fn(&mut A) only. Proposal: an optional run_with(fn(&mut A, &Shell)).
Menu width is style-wide only. Proposal: DropdownChain::min_width(..).
A closed menu stays in the tree through its exit animation, so headless tests must advance time. Proposal: an "is open" query on Placed.
Read against main at c8b928c (v0.1.0-m8.43). For each item: where it lives now, the smallest API that closes the gap, what it breaks, how it meets #315 (the options layer) and #320 (.named everywhere), and a rough size. Q marks a choice for the user, with my recommendation first.
1. Dropdown trigger content and a trailing chevron
Now
DropdownChain (src/owned/menu.rs:736) holds a Face and ButtonOptions. It builds its trigger with ButtonChain::new(..) at menu.rs:832.
Its only content option is a leading icon (menu.rs:772).
ButtonChain already has children (src/owned/button.rs:438) and Face::Empty(name) (button.rs:47), so the trigger can hold any content. The dropdown just doesn't pass it through.
The select trigger already draws a trailing Chevron::Down (src/owned/select.rs:240).
Smallest API
DropdownChain::children(body), forwarded to the ButtonChain it builds. It's the same signature as ButtonChain::children, used with Face::Empty(name) or alongside a label.
DropdownChain::chevron(): a trailing Chevron::Down drawn as the select draws its own, at the style's indicator size and in the trigger's text colour.
Q1.1: how to spell a trailing glyph.
(a) .chevron(), the stock down-chevron only. Recommended: it covers the case the consumer paints by hand, matches the select, and leaves no glyph or size choice to the caller.
(b) .trailing_icon(Icon) on ButtonOptions, so every button gets it. More general, but a second icon slot on every button is a wider API, and children already covers anything unusual.
(c) Both.
Q1.2: where the chevron sits. Is it decorative only, kept out of the accessible name? Recommended: yes. The trigger already announces HasPopup::Menu and expanded.
Q1.3: the chevron's look. Its size, its gap after the label, and whether it rotates while the menu is open are the user's pick. I'll render candidates beside the select trigger before it lands.
Size: S, about 60 lines plus tests, plus the render round for Q1.3.
2. Check and radio items bound to a command, and a public chord read
Now
Menu::command (menu.rs:276) always builds an Action item.
Check and radio items exist only as plain items: checkbox_item (menu.rs:312) and radio_item (menu.rs:330).
A Command (src/commands.rs:44) has a title, a run, enabled: fn(&A) -> bool and a chord. Command::chord() is already public (commands.rs:309).
But the table only gives an app Commands::iter() (commands.rs:427), with no keys. Commands::find is pub(crate) (commands.rs:431), and so is Builder::command (src/builder.rs:703). So the app can't look a command up by its key.
Q2.1: where the checked state lives.
(a) On the command (recommended):Command::new(..).checked(fn(&A) -> Mark) for an on/off command, and .chosen(fn(&A) -> Mark) for one of a set.
Menu::command then draws a check or dot item with the matching role (MenuItemCheckBox / MenuItemRadio).
Every reader of the table agrees, because the state is defined once: menus, a command button, a native menu bar walking iter().
This follows the rule that policy shared by several sites is encoded once.
(b) On the item (the issue's proposal): m.command(id).checked(Mark). Smaller, but each menu that shows the command restates its state, and a native menu bar can't see it.
Q2.2: the chord read.
(a) Recommended:Commands::get(&self, id: impl Key) -> Option<&Command<A>>, find made public under the key the app already uses. The app then calls .chord() and .title().
(b) Also Command::shortcut_text(&Context) -> Option<String>, the platform's spelling as the menu shows it. Recommended as well: it saves every reader from calling ctx.format_shortcut itself, and keeps the spelling one rule.
Size: M, about 150 lines plus tests (command state, item drawing, get, shortcut_text).
3. Menu::command returns a pre-filled chain finished by .add()
Now
Menu::command (menu.rs:276) returns (). It builds the item itself: title, formatted shortcut, enablement from the command, and the activation.
So a command item can't take .inset(), .icon() (menu.rs:608, :614), .destructive() or .focus_on_open() (menu.rs:629, :644).
Smallest API
Menu::command(id) -> ItemChain<'_, 'f, A, CommandItem>, with title, shortcut, enablement and the command's check or dot (item 2) filled in, and finished by .add().
An unknown id still reports UnknownCommand and adds a disabled item, through the same chain.
Q3.1: what the chain lets the caller override.
Recommended:
inset, icon, destructive and focus_on_open are allowed.
enablement can only disable further: the item is enabled only while the command is enabled and the caller allows it, so a menu can never run a command its table says can't run.
shortcut (the display text) is not offered, because the table owns the chord.
The alternative is to allow everything and let the caller be wrong. Not recommended.
Q3.2: the finisher's name..add() (recommended): it matches ButtonChain::add, MountChain::add and the issue. The alternative is .done(). Nothing else in the library uses that.
Breaks: yes.
Every m.command(id); becomes m.command(id).add();.
ItemChain is #[must_use], so an unfinished one is a warning, an error under -D warnings. Every call site is found at compile time.
One breaking tag; the migration is mechanical.
Note on the asymmetry with buttons.
ButtonChain::command(id) (button.rs:452) is a finisher, because a button keeps its own label.
A menu item's label is the command's title, so command starts the chain there.
Placed::overlays() and Placed::overlay(key) (src/roots.rs:367, :400) include an overlay that is still on screen during its exit. OverlayRef::is_exiting() (roots.rs:476) tells them apart.
But a dropdown's menu overlay is keyed (key, Part::Menu) with a private Part, so an app can't name it.
Whether a dropdown is open is held in Kept (menu.rs:36).
Q6.1: what the query reads.
(a) Recommended:Placed::menu_open(key) -> bool for the dropdown key. It is true exactly while the menu is logically open, and false on the frame it closes, whatever the exit animation is doing. No time needs advancing in tests.
(b) Placed::dropdown_menu(key) -> Option<OverlayRef> and let callers check is_exiting(). More general, but every caller writes the same two-step check.
A doc fix, separately.Placed::overlay's doc says "None when it is not open", yet it returns an exiting overlay. Either the doc or the behaviour should change.
Q6.2:
Recommended: fix the doc ("open or leaving").
Changing the behaviour would change what existing overlay tests see.
Commands (items 3, 2 and 4). One breaking tag: the command chain with .add(), checked and chosen commands, Commands::get with Command::shortcut_text, and Command::with_shell. They change the same two files and their tests, and the .add() migration happens once.
About M+, about 300 lines.
Needs Q2.1, Q2.2, Q3.1, Q3.2, Q4.1 and Q4.2 first.
A UI trial for the check and dot command items.
Dropdown (items 1 and 5). Additive: children, chevron() and menu_classes.
S+, about 100 lines.
Needs Q1.1, Q1.2, Q5.1 and Q5.2.
A render round for Q1.3 and a UI trial.
Testing (item 6). Placed::menu_open and the overlay doc fix.
S. Needs Q6.1 and Q6.2.
It could ride with PR 2 if the user prefers fewer PRs.
Order:
PR 3 first: it is tiny, and the other two can use it in their tests.
Activity
samitbasu commentedon Nov 18, 2026
Design note for #325 (no code yet)
Read against main at c8b928c (v0.1.0-m8.43). For each item: where it lives now, the smallest API that closes the gap, what it breaks, how it meets #315 (the options layer) and #320 (
.namedeverywhere), and a rough size. Q marks a choice for the user, with my recommendation first.1. Dropdown trigger content and a trailing chevron
Now
DropdownChain(src/owned/menu.rs:736) holds aFaceandButtonOptions. It builds its trigger withButtonChain::new(..)atmenu.rs:832.icon(menu.rs:772).ButtonChainalready haschildren(src/owned/button.rs:438) andFace::Empty(name)(button.rs:47), so the trigger can hold any content. The dropdown just doesn't pass it through.Chevron::Down(src/owned/select.rs:240).Smallest API
DropdownChain::children(body), forwarded to theButtonChainit builds. It's the same signature asButtonChain::children, used withFace::Empty(name)or alongside a label.DropdownChain::chevron(): a trailingChevron::Downdrawn as the select draws its own, at the style's indicator size and in the trigger's text colour.Q1.1: how to spell a trailing glyph.
.chevron(), the stock down-chevron only. Recommended: it covers the case the consumer paints by hand, matches the select, and leaves no glyph or size choice to the caller..trailing_icon(Icon)onButtonOptions, so every button gets it. More general, but a second icon slot on every button is a wider API, andchildrenalready covers anything unusual.Q1.2: where the chevron sits. Is it decorative only, kept out of the accessible name? Recommended: yes. The trigger already announces
HasPopup::Menuandexpanded.Q1.3: the chevron's look. Its size, its gap after the label, and whether it rotates while the menu is open are the user's pick. I'll render candidates beside the select trigger before it lands.
childrenandchevronare dropdown extras, likeButtonOptions's button extras, so they survive the move to oneOptionsvalue unchanged. One thing to flag: One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315 lists a missingtooltipon the dropdown.ButtonOptionsalready carries one viawith_options, so the fix there is a one-line forward. That belongs in One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315, not here.Face::Empty(name)or.named(..)(menu.rs:785). Nothing new is needed.2. Check and radio items bound to a command, and a public chord read
Now
Menu::command(menu.rs:276) always builds anActionitem.checkbox_item(menu.rs:312) andradio_item(menu.rs:330).Command(src/commands.rs:44) has a title, a run,enabled: fn(&A) -> booland a chord.Command::chord()is already public (commands.rs:309).Commands::iter()(commands.rs:427), with no keys.Commands::findispub(crate)(commands.rs:431), and so isBuilder::command(src/builder.rs:703). So the app can't look a command up by its key.Q2.1: where the checked state lives.
Command::new(..).checked(fn(&A) -> Mark)for an on/off command, and.chosen(fn(&A) -> Mark)for one of a set.Menu::commandthen draws a check or dot item with the matching role (MenuItemCheckBox/MenuItemRadio).iter().m.command(id).checked(Mark). Smaller, but each menu that shows the command restates its state, and a native menu bar can't see it.Q2.2: the chord read.
(a) Recommended:
Commands::get(&self, id: impl Key) -> Option<&Command<A>>,findmade public under the key the app already uses. The app then calls.chord()and.title().(b) Also
Command::shortcut_text(&Context) -> Option<String>, the platform's spelling as the menu shows it. Recommended as well: it saves every reader from callingctx.format_shortcutitself, and keeps the spelling one rule.Breaks: nothing. Both are additive.
One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315: One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315's
refused(reason)would pair naturally with a command that can say why it is disabled, ifenabledsomeday returns a reason and not a bool. Out of scope here, but the command-item chain in item 3 should leave room for it.Names follow the web: .named() on every control as the override; bare icon faces allowed and reported #320: a command item's accessible name is the command's title, as now.
Size: M, about 150 lines plus tests (command state, item drawing,
get,shortcut_text).3.
Menu::commandreturns a pre-filled chain finished by.add()Now
Menu::command(menu.rs:276) returns(). It builds the item itself: title, formatted shortcut, enablement from the command, and the activation..inset(),.icon()(menu.rs:608,:614),.destructive()or.focus_on_open()(menu.rs:629,:644).Smallest API
Menu::command(id) -> ItemChain<'_, 'f, A, CommandItem>, with title, shortcut, enablement and the command's check or dot (item 2) filled in, and finished by.add().UnknownCommandand adds a disabled item, through the same chain.Q3.1: what the chain lets the caller override.
inset,icon,destructiveandfocus_on_openare allowed.enablementcan only disable further: the item is enabled only while the command is enabled and the caller allows it, so a menu can never run a command its table says can't run.shortcut(the display text) is not offered, because the table owns the chord.Q3.2: the finisher's name.
.add()(recommended): it matchesButtonChain::add,MountChain::addand the issue. The alternative is.done(). Nothing else in the library uses that.Breaks: yes.
m.command(id);becomesm.command(id).add();.ItemChainis#[must_use], so an unfinished one is a warning, an error under-D warnings. Every call site is found at compile time.Note on the asymmetry with buttons.
ButtonChain::command(id)(button.rs:452) is a finisher, because a button keeps its own label.commandstarts the chain there.#315 and #320:
If One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315 gives
ItemChaintheConfiguretrait,enablementmust keep the AND rule from Q3.1. Its default method would replace the value, soCommandItemneeds its own impl.The item's name is the title, so
.namedon items isn't needed for Names follow the web: .named() on every control as the override; bare icon faces allowed and reported #320.Size: S to M, about 100 lines plus migrating the library's own examples and tests.
4.
run_with(fn(&mut A, &Shell))Now
Run::Plain(fn(&mut A))(commands.rs:228) comes fromCommand::new(commands.rs:257).Command::firealready holds a&Shell(commands.rs:323) and passes it only to paste.enabledisfn(&A) -> bool(commands.rs:52).Q4.1: how a command that gets the shell is spelled.
Command::with_shell(title, fn(&mut A, &Shell)), besideCommand::paste(title, run).Copy, made of fn pointers..run_with(..)on a built command, replacing the runnewwas given. That reads as two runs, and it is easy to set both.Q4.2: whether
enabledgets the shell too.Recommended: not until a caller needs it. Enablement is read while building, where the
Shellis the one being built. Adding it later is additive.Breaks: nothing.
One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315 / Names follow the web: .named() on every control as the override; bare icon faces allowed and reported #320: no interaction.
Size: S, about 40 lines plus a test that the shell reaches the command from a chord, a menu item and a command button.
5. Per-menu width
Now
MenuStyle::min_width(src/contract.rs:691) is applied to every menu box atmenu.rs:570.DropdownChain, or onNodeHandle::context_menu(builder.rs:1987).Q5.1: the shape.
menu_classes(Tw)onDropdownChain, merged over the menu box's classes.min_w_px,w_px) and anything else a box takes (max_h), with no new numeric argument.classes(Tw)on the trigger.min_width(Distance): exactly what was asked, and typed (no naked float). But the next request (a max height, a fixed width) needs another method.Q5.2: context menus too.
The question is whether
context_menutakes the same option, or whether that waits.Recommended: wait.
context_menutakes only an items closure today, and widening its signature is a separate decision.Breaks: nothing.
One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315: (a) fits One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315's "classes merge everywhere".
Size: S, about 30 lines plus a test.
6. An "is open" query on
PlacedNow
Placed::overlays()andPlaced::overlay(key)(src/roots.rs:367,:400) include an overlay that is still on screen during its exit.OverlayRef::is_exiting()(roots.rs:476) tells them apart.(key, Part::Menu)with a privatePart, so an app can't name it.Kept(menu.rs:36).Q6.1: what the query reads.
Placed::menu_open(key) -> boolfor the dropdownkey. It is true exactly while the menu is logically open, and false on the frame it closes, whatever the exit animation is doing. No time needs advancing in tests.Placed::dropdown_menu(key) -> Option<OverlayRef>and let callers checkis_exiting(). More general, but every caller writes the same two-step check.A doc fix, separately.
Placed::overlay's doc says "Nonewhen it is not open", yet it returns an exiting overlay. Either the doc or the behaviour should change.Q6.2:
Breaks: nothing.
One options layer for owned controls: Options, Configure/Interactive traits, refused(reason), when/when_some #315 / Names follow the web: .named() on every control as the override; bare icon faces allowed and reported #320: no interaction.
Size: S, about 30 lines plus a test.
Proposed PR split
.add(), checked and chosen commands,Commands::getwithCommand::shortcut_text, andCommand::with_shell. They change the same two files and their tests, and the.add()migration happens once.children,chevron()andmenu_classes.Placed::menu_openand theoverlaydoc fix.Order:
samitbasu commentedon Nov 18, 2026
Decisions (user, 2026-11-17), on the design note:
Command::checked(..)/.chosen(..).m.command(id)returns a pre-filledItemChainfinished by.add()(breaking). Enablement only ANDs with the command's.Command::with_shell(title, |app, shell| …)constructor.menu_classes(tw)on the dropdown.The other flagged questions take the note's recommendations, listed in each PR for review. The chevron's look gets a render round in the dropdown PR.