PopupSelect
HkPopupSelect is a controlled selector: a field-shaped trigger plus an anchored list popout, with a bottom sheet on phones. It exists for dense rows that would read oversized as a stock <select> — a filter condition's value, a toolbar's unit, a table cell's owner — and it is the smallest component in this group that is a complete control rather than a surface.
- Reach for it where a native <select> cannot carry the row anatomy (a second description line, a checked marker, a scroll cap) and where the surrounding row already names the field (hideLabel). For a plain form field use Select; for a panel whose content is not a value list use Popover.
- It consumes the rest of this group. In Vue it renders HkPopover for the layer (placement="bottom", offset: 4, backdrop: false, sheetOnMobile, the field label as the sheet title) and HkScrollContainer for the scrolling viewport. In Rust it mounts the mirrored Popover with exactly those props — the anchored geometry comes from feedback::popover::popover_position_style through that mirror — so this page's surface behaviour is Popover's, and the field behaviour is its own.
- The list rows carry the same data-highlighted / data-select-index / data-checked grammar as SelectPanel; the two components are siblings, not layers of each other.
Import
;
from "@celestia-island/hikari";
use *; // PopupSelect, PopupSelectOption, PopupSelectSize, PopupSelectRow,
// popup_select_display_label, popup_select_trigger_value,
// popup_select_rows, popup_select_open_highlight,
// popup_select_key_action, popup_select_viewport_style,
// popup_select_trigger_classes
use *; // PopupSelectProps, PopoverAnchorRect, rsx!, VNode, EventHandler
The Rust form is PopupSelect(PopupSelectProps { … }). Vue takes a default slot of HkPopupSelectOptions as well as the options prop; the Rust mirror renders options only. The anchor is a PopoverAnchorRect (Vue measures its own triggerRef) and is passed through to the reused Popover.
The trigger: what it says, and how it steps
The trigger's text is the placeholder while the model is empty, otherwise the matching option's label, otherwise the raw value — popup_select_display_label is the exported statement of that fallback chain, and popup_select_trigger_value adds the last guard (an empty resolved label falls back to the placeholder again). The chevron is 16px at md and 14px at sm, and data-state reports open / closed.
The keys, re-expressed as the pure popup_select_key_action(key, open):
- Enter / Space — toggle.
- ArrowDown / ArrowUp while closed — open (Vue then re-seeds the cursor from the model through a watcher; popup_select_open_highlight is that seed).
- ArrowDown / ArrowUp while open — step the cursor, wrapping.
- Escape while open — close and consume, so a surface hosting this selector keeps its own Escape; while closed — a quiet no-op that keeps bubbling.
Selected: inbox
Both cards show the closed control: div.hk-popup-select-wrapper → label.hk-popup-select-label → button.hk-popup-select-trigger[data-state="closed"] with span.hk-popup-select-value reading "Inbox" and the chevron. That is not a limitation of the Rust example — it is the honest default, because open is false on both sides until someone opens it. The TSX card is live: press it, step with the arrows, pick a row; the Rust card renders the frame its props describe and reports the chosen value through on_value_change.
Provenance gap (Rust). The reused Popover has no Teleport, so the layer paints in place with inline position: fixed geometry derived from anchor. Give a Rust PopupSelect an explicit anchor (as the second example below does) or the popover falls back to the stylesheet's default box — and in a static render the data-hk-outside shield attribute is absent (no page to listen on), which is expected, not broken.
The open frame, and the row anatomy
An option with a description grows a two-line body (span.hk-popup-select-item-body → -label + -desc); an option without one keeps the exact stock row — a bare label span, no wrapper, no optical shift. That asymmetry is deliberate upstream (the R2 contract): the described anatomy must not leak into rows that have nothing to describe.
open, highlighted_index and anchor are controlled on the Rust side (on_open_change / on_highlight_change writers), because the crate stores nothing; Vue keeps all three in locals and coordinates instances through a module-level activePopupId singleton so only one popup is open at a time.
The Rust card is the open frame, written as props: open: true, the cursor on row 1, and an anchor rect — because a snapshot cannot press a trigger. What it paints is the reused popover's layer (div[data-hk-popout-layer] → div.hk-popover-panel.hk-popover-bottom.hii-dropdown-content.hk-popup-select-content) with div.hk-popup-select-viewport inside and one div.hk-popup-select-item per option, data-highlighted on the second and data-checked on the first. The TSX card starts closed — press it to see the same layer for real, with the two-line row and the stock rows side by side.
[D] No cross-instance singleton. Vue's activePopupId closes every other open popup when one opens. The Rust mirror stores nothing, so a host that wants "one open at a time" keeps a shared open id in its own state and renders the others closed.
[D] No scrollIntoView. Vue queries [data-select-index="…"] and scrolls the cursor into view; the mirror emits the same data-select-index hook so a host can, but the cursor itself only moves.
[D] No HkScrollContainer. That component has no Rust mirror, so .hk-popup-select-viewport is rendered directly with the container's two jobs written inline (popup_select_viewport_style(): the flex column, --space-2 gap and inset, and overflow-y: auto so the panel's own 240px cap scrolls instead of clipping). The overlay-scrollbar chrome is absent by the same rule.
Size, label, error and the no-caption variant
size is the density step: md is the form-field stock (2.5rem trigger) and sm the compact one (2rem) for dense rows — the same split DatePicker and Input carry. error colours the trigger (data-error keeps the message string verbatim) and renders a p.hk-popup-select-error line below the control. required appends the * marker inside the caption.
hideLabel suppresses the caption while keeping label semantic: the trigger takes it as aria-label and the sheet keeps it as its heading. That is the shape FilterPanel's [field | operator | value] grid needs — the field is already named in the row, so a second caption above the control reads as duplication.
Pick a scope before saving.
Both cards render the caption-less, erroring control: no label.hk-popup-select-label, aria-label="Scope" on the trigger instead, data-error="Pick a scope before saving." on it as well, and the message line below. Note what required does once hideLabel is on: the * lives inside the caption, so there is no caption to mark — the required flag has no visible effect in this shape on either side. If the shape must say "required", say it in the placeholder or in the error text.
[D] Trigger markup differs below the sm step. Vue renders class={["hk-popup-select-trigger", ""]} for md (an empty array entry); the Rust mirror drops the empty step so the class list never serializes a doubled space. Cosmetic, but it means a strict class="…" string comparison between the two trees will differ for every md selector.
[D] The disabled attribute is serialized differently. Vue renders the bare boolean disabled; the Rust mirror writes disabled="true". Both are valid HTML and both match [disabled], but a host that queries or asserts on the exact attribute string will see a mismatch. Test with [disabled], never [disabled="true"].
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| modelValue | String | "" | — |
| label | String | undefined | — |
| placeholder | String | "" | — |
| error | String | undefined | — |
| disabled | Boolean | false | — |
| required | Boolean | false | — |
| size | <code>String as PropType<"sm" | "md"></code> | "md" | — |
| hideLabel | Boolean | false | — |
| options | Array as PropType<HkPopupSelectOption[]> | undefined | — |
Emits
| Event | Payload |
|---|---|
| update:modelValue | string |
Rust
Props — PopupSelect
| Prop | Type | Default | Description |
|---|---|---|---|
| model_value | String | "" | Vue: modelValue, default "". |
| label | Option<String> | None | The caption above the control (Vue: label). |
| placeholder | String | "" | Shown while the model is empty (Vue default ""). |
| error | Option<String> | None | Error ink + message line (data-error on the trigger). |
| disabled | bool | false | — |
| required | bool | false | Appends the * marker to the caption (Vue: required). |
| size | PopupSelectSize | PopupSelectSize::Md | Control density (Vue default "md"). |
| hide_label | bool | false | Suppress the caption while keeping label semantic: the trigger takes it as aria-label and the sheet keeps it as its heading (Vue: hideLabel). |
| options | Vec<PopupSelectOption> | [] | The choice model. |
| open | bool | false | Popup visibility (Vue: the local isOpen). |
| highlighted_index | i32 | -1 | Keyboard/pointer highlight; -1 means "none" (Vue: the local highlightedIndex). |
| anchor | Option<PopoverAnchorRect> | None | The trigger rect the popout anchors against — Vue's triggerRef (feedback::popover::anchor_rect_from_element_id measures one by id). |
| class | String | "" | Host class on the wrapper (Vue: attrs fallthrough on the root). |
| on_open_change | Option<EventHandler<bool>> | None | Fires with the desired open state (Vue: the local ref's writer). |
| on_value_change | Option<EventHandler<String>> | None | Fires with the chosen option value (Vue: update:modelValue). |
| on_highlight_change | Option<EventHandler<i32>> | None | Fires with the desired highlight index. |
Accessibility
- The trigger is a real button type="button"; when the caption is hidden it is named by aria-label={label}, so hideLabel never costs the control its name. Keep label set even when you hide it.
- The popup is Popover's: a role="dialog" panel named by the field label, docked as a blocking sheet on phones with a grabber and a ✕. The rows themselves are plain divs carrying data-* markers — this control is a listbox in appearance only, and no role="listbox" / aria-activedescendant is emitted on either side. If a page needs listbox semantics, the host supplies them around this control.
- Arrow keys move a highlight that is a visual cursor, not the selection: the value changes only when a row is pressed or Enter is used, and Escape closes one layer only.
- error is rendered as text and as data-error on the trigger; the message is not wired to aria-describedby or aria-invalid on either side. If a validation failure must be announced, the surrounding form field has to carry it.
- required is visual: there is no aria-required on the trigger, and on the hideLabel shape the marker is not rendered at all.
- A disabled trigger does not open on click or on any key (popup_select_key_action is only consulted when not disabled) — but the caption is still rendered, so a disabled field keeps its name.
Related components
- Popover — the layer this control mounts.
- SelectPanel — the other dropdown surface, for custom content instead of a value list.
- Select — the stock field, when a native-looking control is enough.
- FilterPanel — the row grid hideLabel was designed for.