Skip to main content
cngx-src documentation

CNGX_HIERARCHICAL_NAV_STRATEGY

Tokenv0.1.0WCAG AA

InjectionToken<CngxHierarchicalNavStrategy>

Description#

DI token carrying the CngxHierarchicalNavStrategy that CngxHierarchicalNav consults on every ArrowLeft/Right press. Defaults to createW3CTreeStrategy; override via providers/viewProviders for alternative keyboard semantics.

bootstrapApplication(AppComponent, {
  providers: [
    {
      provide: CNGX_HIERARCHICAL_NAV_STRATEGY,
      useFactory: () => ({
        onArrowRight: (ctx) => {
          // Expand only; never traverse to first child.
          const node = ctx.controller.findById(ctx.activeId);
          if (!node?.hasChildren) return { kind: 'noop' };
          ctx.controller.expand(ctx.activeId);
          return { kind: 'expand', id: ctx.activeId };
        },
        onArrowLeft: (ctx) => ({ kind: 'noop' }),
      }),
    },
  ],
});

Type#

InjectionToken<CngxHierarchicalNavStrategy>

Provided in#

'root'