Primitives / foldkit-primitives/dom

FocusReturn

const · packages/primitives/src/dom/focus-return.ts:62

const FocusReturn: Mount.MountDefinitionNoArgs<'FocusReturn', never>

Gives focus a way back for an overlay whose own restoring is not ours (a Dialog's: it returns to its opener, and to body when that is gone). It takes the opener when the overlay mounts; when the overlay unmounts with focus lost (on body, or inside it), focus goes back to the opener, else by the rules of fallBack. Focus the user moved elsewhere is left alone, and nothing is focused on mount: FocusScope does that. It sends no Message. It opens a layer of the document's stack while mounted, so the layers opened before it read as covered: a FocusScope below contains nothing meanwhile, and a HideOutside below leaves this overlay shown.

In the guides