function / @typed/ui/Composite

moveAndFocus

Moves active state, then focuses and scrolls the mounted active item when virtual focus is disabled.

Learn this UI primitive →

Package version
1.0.0-beta.7
Category
DOM focus and scrolling
Since
1.0.0

Import

import { moveAndFocus } from "@typed/ui/Composite";

Signatures

export declare function moveAndFocus<Value, CompositeState extends State, E, R, E2, R2, Element extends object>(options: MoveOptions<Value, CompositeState, E, R, E2, R2, Element>, direction: Move): Effect.Effect<CompositeState, E | E2, R | R2>;

Why

The operation exposes Composite’s transition directly so callers can compose it in Effect programs and native event handlers.

Ownership and lifetime

The returned Effect performs the update or DOM side effect only when run, preserves the declared error and service channels, and retains no resources after completion.

Example

Import with import { moveAndFocus } from "@typed/ui/Composite"; Extend the Composite.makeState runnable setup. Inside the linked Effect program run yield* moveAndFocus({ state, collection }, "next"); the returned state names the next id and its registered element receives native focus.

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source