Primitives / foldkit-primitives/dom
FocusScope
const · packages/primitives/src/dom/focus-scope.ts:29
const FocusScope: Mount.MountDefinitionWithArgs<
'FocusScope',
{
contain: Schema.Boolean
restore: Schema.Boolean
initialFocus: Schema.NullOr<Schema.String>
},
never
>A focus scope as a Mount: on insert it remembers what was focused, focuses
an initial element inside, and with contain keeps Tab and Shift+Tab
cycling inside; on unmount it gives focus back to what had it, or, when that
is gone and focus is lost with the scope, where fallBack finds a place. It
is a layer of the
document's stack while mounted, and a scope with a layer opened after it
still open contains nothing: the topmost layer owns containment, so a
dialog drawn beside this one, as a portaled one is, keeps its focus.
Nothing crosses to the
Model: which element had focus is a DOM fact, so this is element lifecycle,
not state. It emits no Messages.