sdxc
SearchCtrlK

[ @sdxc/ui/mixins ]

activeDescendantKeys

The combobox keyboard pattern over options a server rendered.

import { activeDescendantKeys } from "@sdxc/ui/mixins";

Usage

Moves the choice through the controlled options: Down from the host to the first and around from the last, Up back toward the host. Enter follows the chosen option, or the only option when none is chosen and the listbox sits in no aria-busy region, so stale rows never open.

Signature

activeDescendantKeys(): MixinDescriptor<HTMLElement>

Examples

<input role="combobox" aria-controls="search-options" mix={[activeDescendantKeys()]} />

The events, constants and types its module publishes, each imported from @sdxc/ui/mixins too.

Function

chosenOption

The index of the option combobox has chosen, or -1 while the combobox itself is the choice. The choice lives in aria-activedescendant, so it reads the same to every caller.

chosenOption(combobox: HTMLElement): number
ParameterTypeDescription
comboboxHTMLElementThe element carrying aria-controls and aria-activedescendant.
Function

chooseOption

Chooses the option at index, or none for -1, marking it aria-selected and scrolling it into view. Call it after replacing the options, since a new list starts with whatever choice its markup carries.

chooseOption(combobox: HTMLElement, index: number): void
ParameterTypeDescription
comboboxHTMLElementThe element carrying aria-controls.
indexnumberThe option to choose, or -1 to choose none.

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.