SearchTrigger

SearchTrigger

HkSearchTrigger is the header search affordance — the exact chrome twin of FilterTrigger: a ghost icon button on the chrome action ladder (ghost/32 wide, ghost/28 narrow) with a Search glyph, anchoring a one-field keyword panel, and wearing the same green bottom-right dot while a keyword is active. "This page is filtered" and "this page is searched" therefore read the same at a glance, and the two buttons sit in the same header row.

  • Reach for it when a page searches a text namespace (a roster, a catalogue) with one keyword. For a search field that is always visible, use SearchInput directly; for structured conditions, FilterTrigger or FilterPanel.
  • What matches the keyword is the host's business — each page maps it onto its own columns. This component owns one trigger, one panel and one keyword.
  • The keyword has first-class clearing: an empty draft commits "" immediately, and clearing never needs a separate verb.

Import

tsx
1
import { HkSearchTrigger } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // SearchTrigger
use hikari_components::prelude::*; // SearchTriggerProps, rsx!, VNode, EventHandler

The Rust form is SearchTrigger(SearchTriggerProps { … }). It takes the keyword (model_value) plus placeholder, label, debounce, min_length, placement, narrow, and three controlled props of its own (open, draft) with their writers. Inside rsx! everything may be omitted: no keyword, no placeholder, debounce 300, min_length 1, bottom-end.

The commit model: draft, debounce, minimum length

The panel holds a local draft that commits to modelValue on three edges: debounced while typing (default 300 ms; the timer lives inside HkSearchInput), immediately on Enter, and immediately when the draft becomes empty. The last one matters — a debounced clear would leave the active dot lingering after the field looked empty. A non-empty draft shorter than minLength (floored at 1) does not commit, so panel edits stay free until they are committable; the empty draft always passes, because clearing is a verb, not a query. A draft equal to the active keyword is a no-op.

Closing the panel flushes the draft (commit(draft)), so a keystroke inside the debounce window still reaches the host — the popover tears down, and that teardown kills the input's timer.

Keyword: atlas

Both cards start with an active keyword ("atlas") and a lit dot. Open the TSX trigger and type: the keyword updates debounced, Enter commits at once, and emptying the field clears the dot immediately. The Rust card is a snapshot of the closed trigger — the panel and the typing never execute there.

One state, two forms: what Vue keeps in refs, Rust takes as props

Vue keeps three things inside the component: open, the draft, and (via the popover) focus. The Rust form takes open and draft as props and reports through on_open_change, on_draft_change and on_value_change; the open-edge seed (draft := model_value when the panel opens) and the input's focus grab are host work, because the mirror has no watcher and no element handles. The commit gate is exported as the pure search_trigger_commit_value(value, min_length, model_value, disabled), and every writer — the input's search event, the immediate clear, the Apply flush — goes through it.

The debounce is also the host's in Rust: the mirrored SearchInput documents that no render-scoped timer survives a re-render on this runtime, so debounce is accepted and inert there and onsearch fires on Enter only. A Rust host that wants the 300 ms window schedules it itself and calls the commit gate when it elapses.

The narrow frame adds the one confirm button ("Apply"), which flushes the draft and then closes — the same order Vue's close handler uses.

The two Rust triggers are the panel open on each footprint — wide with the bare input, narrow with the Apply footer — and both sit above their anchors so the panel stays inside the frame. The Rust form opens a panel only by open: true; a snapshot cannot click.

The two reading states

The trigger has exactly two faces a reader needs to tell apart: no keyword, and a keyword committed. Nothing about the keyword's content shows in the chrome — the dot is the only signal, so the states are what matter, and the snapshot can paint both.

One card cannot show a keyword commit without someone typing it, so the Rust column carries both states side by side: the bare trigger, and the trigger with "atlas" committed and its dot lit. The TSX card shows the bare one; open it, type, and press Enter to reach the same second frame.

Disabled, placement and the page's other affordance

disabled disables the trigger and the input, and disables the commit path (the Rust gate returns None for a disabled component, so even a clear cannot fire). placement defaults to bottom-end on both sides. The Rust layer is inline geometry against the trigger's position: relative: no measurement, no auto-flip, no viewport clamp, and no outside-click close — the host closes it, and when it does, it must run search_trigger_commit_value(draft, …) first to get the same last-keystroke flush the Vue teardown performs. On the narrow footprint the host must also decide what happens to the mobile bottom-sheet presentation, which Vue gets from its popover runtime.

The Rust card is the disabled trigger with an active keyword — the dot still lights, because the page is still searched; pressing it can no longer open or commit. The TSX card is disabled with no keyword.

API

Vue

Props

NameTypeDefaultRequired
modelValueString""—
placeholderStringundefined—
disabledBooleanfalse—
labelStringundefined—
debounceNumber300—
minLengthNumber1—
placementString as PropType<PopupPlacement>"bottom-end"—

Emits

EventPayload
update:modelValuestring

Rust

Props — SearchTrigger

PropTypeDefaultDescription
model_valueString""The ACTIVE keyword ("" = none).
placeholderOption<String>NoneInput placeholder; None falls back to the search input's own localized "Search…" (Vue: placeholder).
disabledboolfalse—
labelOption<String>NoneAccessible name / panel title; defaults to the localized "Search" — the same word the icon says (Vue: label).
debouncef64300.0Commit debounce while typing, in ms (Vue default 300; ACCEPTED AND INERT — the host owns the window, see the header deltas).
min_lengthu321Drafts shorter than this do not commit (Vue default 1).
placementPopoverPlacementPopoverPlacement::BottomEndLayer placement against the trigger (Vue default "bottom-end").
narrowboolfalseVue's useBreakpoint().isMobile stand-in: the host passes platform::inner_width() < 768.
openboolfalsePanel visibility.
draftString""The LOCAL draft inside the panel (seeded from model_value on the opening edge — the host's write).
on_open_changeOption<EventHandler<bool>>NoneFires with the desired open state (Vue: the local open writes).
on_value_changeOption<EventHandler<String>>NoneFires with the next ACTIVE keyword (Vue: update:modelValue).
on_draft_changeOption<EventHandler<String>>NoneFires with the panel draft's new text (the Rust-side writer for Vue's local draft ref).

Accessibility

  • The trigger is a real button named by label ("Search"), with aria-haspopup="dialog" and a live aria-expanded. The default name is the same word the icon means, which is the point: the icon and the accessible name agree.
  • The active dot is aria-hidden decoration. If the keyword's presence matters to a screen-reader user, state it elsewhere — the result count line, or a labelled "clear search" control on the page.
  • The input inside the panel is named by SearchInput's own contract: a localized "Search…" placeholder, and a clear button with its own aria-label ("Clear search" by default; clearAriaLabel / clear_aria_label overrides it). A placeholder is not a name, so when the panel is the page's only search field, name it — a visible caption, or an aria-label on the field through the host's own wrapper.
  • Committing on Enter is announced nowhere by this component — a search result list should carry a polite live region ("12 results for atlas") so the keyboard user learns what happened without leaving the field.
  • Clearing is immediate by design; a user who deletes the last character gets the unfiltered page back without a confirm step. Say so in the page's empty state rather than adding a confirm dialog.
  • The Rust layer has no focus management: the host focuses the input when open turns true and returns focus to the trigger when it closes.

Related components

  • FilterTrigger — the twin affordance: same chrome step, same dot, condition rows instead of a keyword.
  • FilterBar — the standard filter strip, when a page carries both surfaces.
  • FilterChip — a facet chip, for filtering one known option set.
  • SearchInput — the bare field, when the search box should always be visible.