Skip to main content
cngx-src documentation

connectRecyclerToActiveDescendant

Functioncommon/data/recycler

projects/common/data/recycler/connect-recycler-active-descendant.ts

Description#

Wires a CngxRecycler to a CngxActiveDescendant in virtual mode.

When the AD directive navigates to an item whose index is not in the recycler's rendered range, it sets pendingHighlight (via the virtualCount path). This helper watches that signal and scrolls the recycler to the target index; AD's own effect observes the resulting DOM update and clears the pending state automatically (see the pendingHighlightState.set(null) branch in CngxActiveDescendant after a re-render brings the target into the rendered range).

Unlike * connectRecyclerToRoving}, we don't re-focus a DOM element after the scroll — AD doesn't move real focus, it only rebinds aria-activedescendant. Once the target index enters the rendered range, the [attr.aria-activedescendant] binding on the combobox trigger resolves to the now-present option element for free.

Must be called in an injection context (typically a component constructor) on the same component that owns both the recycler and the AD directive.

Signature#

connectRecyclerToActiveDescendant(recycler: CngxRecycler, ad: CngxActiveDescendant)

Parameters#

@paramrecyclerCngxRecycler

Returns#

void