resolveStepFrom
projects/core/nav/step-resolver.ts
Description#
Resolve the next enabled index from current in direction, skipping
disabled indices, wrapping under loop, or null when no enabled index
is reachable. The shared kernel of every next/prev-with-disabled-skip
iterator (active-descendant, roving tabindex, stepper strip, chip-strip
roving) - previously four private copies.
Arithmetic contract (ported exactly from the active-descendant strategy, the strictest of the four sites):
- A negative
currententers from the approach edge:-1when stepping forward (first probe is index0),countwhen stepping backward (first probe iscount - 1). current >= countis NOT remapped - every probe is bounds-checked, so the first out-of-range probe resolves tonullwithoutloopand wraps via modulo with it.- At most
countprobes run; a fully disabled range resolves tonull.
Callers with clamp semantics (stop at the boundary, keep the current
index) compose the resolver as resolveStepFrom(...) ?? current.
Like resolveInlineStep, this is a pure function, not a DI
chokepoint - each strategy owns its isDisabledAt adapter and calls it
directly. The direction axis (RTL arrow flip) stays in resolveInlineStep;
this kernel owns only the index axis.
Signature#
resolveStepFrom(current: number, direction, scan: CngxStepScan)Parameters#
The index to step from.
1 steps forward, -1 backward.
The range description.
Returns#
number | null The next enabled index, or null when none is reachable.