Skip to content

@jsvision/ui / FocusHost

Interface: FocusHost

Defined in: ui/src/router/types.ts:78

The focus seam an application hands to a router-style body so it can save and restore keyboard focus across navigation — restoring the exact field a warm screen had focused, or the same-position field of a rebuilt one. createApplication implements it over the event loop. A standalone-mounted router (no application) gets none, and the loop's own focus-healing provides the first-focusable floor automatically.

Example

ts
// Restore the previously focused view when returning to a screen:
const previous = focus.getFocused();
// …navigate away and back…
if (previous !== null) focus.focusView(previous);

Methods

focusView()

focusView(view): void

Defined in: ui/src/router/types.ts:80

Move keyboard focus to view (a no-op if the view is not currently mounted).

Parameters

view

View

Returns

void


getFocused()

getFocused(): View | null

Defined in: ui/src/router/types.ts:82

The currently focused view, or null when nothing holds focus.

Returns

View | null