Skip to main content
cngx-src documentation

CngxChipStripRovingController

Interface

projects/common/interactive/reorder/chip-strip-roving.ts

Import#

import { CngxChipStripRovingController } from '@cngx/common/interactive'

Description#

Controller produced by createChipStripRoving. Exposes an activeIndex signal the consumer binds into [attr.tabindex]="i === roving.activeIndex() ? 0 : -1", plus a keyboard handler and imperative focus helpers.

Index#

Instance Properties#

activeIndex#Signal
Readonly

Current roving position. Clamped to [0, count - 1]; resets to 0 when count drops to 0.

Methods#

focusAt#void
focusAt(index: number)

Imperatively set the active index and focus the corresponding chip. Used by consumers to restore focus after a reorder settles on a new position.

@paramindexnumber
handleKeydown#void
handleKeydown(event: KeyboardEvent)

Keyboard handler for the chip-strip container. Handles plain ArrowLeft / ArrowRight / ArrowUp / ArrowDown / Home / End - moves activeIndex and focuses the chip at the new position. Events carrying any of Ctrl / Alt / Meta are ignored (modifier-gated keys belong to the paired CngxReorder directive).

@parameventKeyboardEvent
markFocused#void
markFocused(index: number)

Announce that a chip at index received focus - typically wired on the chip wrapper's (focus). Idempotent; keeps the active index in sync with whatever the user's focus sequence did (mouse click, Tab into the strip, etc.).

@paramindexnumber
setActive#void
setActive(index: number)

Imperatively set the active index without moving focus. Useful during a reorder's transient pre-render phase where the DOM has not yet re-ordered the chips.

@paramindexnumber