Primitives / foldkit-primitives/dom

FocusRecovery

const · packages/primitives/src/dom/focus-recovery.ts:179

const FocusRecovery: Mount.MountDefinitionWithArgs<
  'FocusRecovery',
  {
    fallback: Schema.$Record<
      Schema.String,
      Schema.$Array<
        Schema.Union<
          readonly [
            Schema.Literals<
              readonly ['same', 'next', 'previous', 'parent', 'stop', 'owner']
            >,
            Schema.Struct<{ readonly part: Schema.String }>,
          ]
        >
      >
    >
  },
  never
>

Recovers focus for a container of parts, as a Mount. While focus is on a marked part (FocusRecovery.behavior draws the marks), the container remembers it; when that element is removed, hidden, made inert or disabled and focus is lost with it, focus goes to the first element the part's fallback steps find, in the same task as the change and before the browser's own fix-up. Nothing is done when focus has moved elsewhere, and nested containers decide once: the innermost one, then outward through foldkit-plus:focus-unrecovered. It sends no Message: the part's OnFocus tells the Model where focus went.