Repository navigation
Extras: the command feature, a command palette, Combobox and Autosuggest (#345) - #401
Conversation
…est (#345) The widgets of #345, in eggshell-ui-extras behind the `command` feature, on core's public API (moving to the widgets crate with #366). - `filter`: the one filter all three use. `word_prefix(query, Candidate)`: each query word must start a word of the label or of a hidden keyword, case and accents aside (Unicode decomposition, via `unicode-normalization`); the start of the label ranks before a later word, before a keyword; ties keep the app's order. An app overrides it with `.filter(|query, candidate| -> Option<Score>)`, or filters itself with `.filtering(Filtering::App(Pending::Loading | Pending::Settled))` and `.on_query(..)`. - `CommandExt::command_list(key)`: a search field (`Role::ComboBox`) over the matching items in a virtual list it drives (`keys_from`), first match highlighted, with groups from the caller (`Items::group`, `Items::commands` for a #325 table), keywords, shortcuts, checks and disabled rows, and an empty state. - `CommandExt::command_dialog(key, Open, on_close)`: the same list in a centred modal dialog; a pick runs the item, then closes it. The app opens it with a #325 command bound to Cmd/Ctrl+K, so it shows in menus and #357 keeps the browser off the chord. - `CommandExt::combobox(key, Option<V>, options)`: a select-like trigger that opens a popover holding the list; the chosen option is checked, a pick runs `on_change` and closes it. - `CommandExt::autosuggest(key, text, suggestions)`: a text field (`Role::ComboBox`) with matching suggestions under it, none highlighted until the arrows move, so Enter is still the field's; a pick or Escape puts them away until the next edit. The look is provisional (the menu's item, heading and shortcut looks, the select's trigger), pending the user's pick in the render round. The `command_palette` example: a Ctrl+K palette over a command table and a page list, a combobox and an autosuggest; its tests drive all three. Part of #345. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
A focused text field keeps Escape from the overlay's dismissal, so the autosuggest reads it from its own field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
|
Render round for #345's 13 looks The sheet is at
Before this is approved, please try it yourself: 🤖 Generated with Claude Code |
|
Looks decided (user, 2026-11-19):
From now on, render rounds must cite the current shadcn registry source file for each |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
… current look The combobox is rebuilt to shadcn's current Combobox (registry/bases/radix/ui combobox.tsx): a field you type in, inside the select's box with the ring while it has focus, a ghost icon-xs chevron at the end (a clear button in its place while there is a value and `on_clear` is set), and the list below the box, 6 pt apart and as wide as it, with no search field of its own. Typing filters and opens it; a click, the chevron or ArrowDown opens it; Escape or a press outside closes it and puts back the chosen label. The list takes shadcn's current command look through a new CommandStyle (installed by the shadcn preset): the highlighted row is bg-muted with foreground text, the search group is h-8 rounded-lg with bg-input/30 and border-input/30 inside a p-1 pb-0 wrapper, the list stops at max-h-72, a group heading is muted text-xs, and a chosen mark sits after the label. A scroll container is as tall as it is told, so a list built with only a max height collapsed to nothing in a render; the list is now told what its rows come to, up to the style's limit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
|
Design approved by the user from the renders (2026-11-19). That covers shadcn's current input-group combobox and the audit's changes: |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
cn-command-list and cn-combobox-list are no-scrollbar (style-vega.css:382, 325); the autosuggest shows the combobox's list. They use Tw::scrollbar_none, so the rows are as wide as the box and no bar sits under the search field. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
Scroll padding and the scrollbar class sit side by side on Tw. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
cn-command-list and cn-combobox-list are scroll-py-1 (style-vega.css:382, 325): the lists use Tw::scroll_py(1.0), so an arrow key never leaves the highlighted row flush with the edge, under the search field. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
|
Approved by the user after the trial, rebuilt to shadcn's current Combobox (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging. |
Fixes #345. Built on #391, #397 (C1) and #400 (keys_from) (and so #381), which are merged in; this diff shows their changes until they land.
The look is provisional: it reuses the menu's item, heading and shortcut looks and the select's trigger. The 13 looks of the design note's §9 are in a render round, waiting for the user's pick (see the comment below). The UI also needs the user's own trial before this is approved:
cargo xtask example command_palette(orcargo xtask web command_palette).API for review (
eggshell_ui_extras::command, featurecommand)CommandExtonBuilder:command_list(key) -> CommandList: an inline search field over the matching items.command_dialog(key, Open, on_close) -> CommandList: the same in a centred modal dialog. A pick runs the item, thenon_close; so does a dismissal. The app opens it with a Menus and commands: trigger content, command items as chains, checked command items, run_with, per-menu width #325 command bound to Cmd/Ctrl+K, so the chord shows in menus and Web: keep the browser off chords an enabled command claims #357 keeps the browser off it.combobox(key, Option<V>, impl IntoIterator<Item = (V, String)>) -> ComboboxChain(V: Key + Copy + PartialEq): a select-like trigger opening a popover with the list. The chosen option is checked; a pick runson_change(app, V)and closes it.autosuggest(key, &str, impl IntoIterator<Item = String>) -> AutosuggestChain: a text field with matching suggestions under it. The field's text is the value; a pick runson_change(app, String).CommandListmethods:placeholder,named,filter,filtering,on_query,empty,classes,items(|items| ..).Itemsmethods:group(heading, |items| ..);item(key, label) -> ItemChain, with.keywords(..),.shortcut(..),.state(CommandState),.enablement(..)and.on_pick(..);commands(heading, &Commands<A>, &A)for a whole Menus and commands: trigger content, command items as chains, checked command items, run_with, per-menu width #325 table: titles, shortcuts, checks and dots, and enabled state; a pick runsCommand::run.ComboboxChainmethods:placeholder,named,filter,empty,classes,on_change.AutosuggestChainmethods:placeholder,named,filter,filtering,classes,on_change.word_prefix(query, Candidate { label, keywords }) -> Option<Score>: each query word must start a word of the label or of a keyword, case and accents aside. The start of the label ranks first, then a later word, then a keyword; ties keep the app's order.Score::new(u32)/Score::BEST(lower ranks first), for an app's own filter.Filtering::{Ours, App(Pending::{Settled, Loading})}: inApp, the app filters itself (cmdk'sshouldFilter={false}) and its items show as given.Open::{Yes, No}(frombool).Behaviour, per the decisions on #345
.filter, or skipped withFiltering::App(a pending state shows a loading row).keys_from), not capped.Accessibility
Role::ComboBoxand owns the keys.Role::ListBox; the field announces that it controls the list, and the highlighted row as its active descendant. Rows areListBoxOption.Dialognamed by.named. The combobox trigger is aComboBoxwith its value,has_popup = Dialogand expanded.Group.Tests (
tests/it/command_palette.rs, which drives the example, plus filter unit tests)Dependency:
unicode-normalization(optional,commandfeature), for accent folding.Checks
cargo xtask ci: exit 0.🤖 Generated with Claude Code