Home / Function/ restoreFocus() — astro Function Reference

restoreFocus() — astro Function Reference

Architecture documentation for the restoreFocus() function in swap-functions.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  437a59db_c7c3_d406_781d_8c6ceae5787f["restoreFocus()"]
  12084e8e_15f3_27ac_8f8b_d442375ff33d["swap-functions.ts"]
  437a59db_c7c3_d406_781d_8c6ceae5787f -->|defined in| 12084e8e_15f3_27ac_8f8b_d442375ff33d
  71513b03_bc12_8c61_def0_12ef28b2be6a["saveFocus()"]
  71513b03_bc12_8c61_def0_12ef28b2be6a -->|calls| 437a59db_c7c3_d406_781d_8c6ceae5787f
  style 437a59db_c7c3_d406_781d_8c6ceae5787f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/transitions/swap-functions.ts lines 141–149

export const restoreFocus = ({ activeElement, start, end }: SavedFocus) => {
	if (activeElement) {
		activeElement.focus();
		if (activeElement instanceof HTMLInputElement || activeElement instanceof HTMLTextAreaElement) {
			if (typeof start === 'number') activeElement.selectionStart = start;
			if (typeof end === 'number') activeElement.selectionEnd = end;
		}
	}
};

Domain

Subdomains

Called By

Frequently Asked Questions

What does restoreFocus() do?
restoreFocus() is a function in the astro codebase, defined in packages/astro/src/transitions/swap-functions.ts.
Where is restoreFocus() defined?
restoreFocus() is defined in packages/astro/src/transitions/swap-functions.ts at line 141.
What calls restoreFocus()?
restoreFocus() is called by 1 function(s): saveFocus.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free