MCPcopy Create free account
hub / github.com/github/awesome-copilot / getFocusableElements

Function getFocusableElements

website/src/scripts/modal.ts:473–486  ·  view source on GitHub ↗

* Get all focusable elements within a container

(container: HTMLElement)

Source from the content-addressed store, hash-verified

471 * Get all focusable elements within a container
472 */
473function getFocusableElements(container: HTMLElement): HTMLElement[] {
474 const focusableSelectors = [
475 "button:not([disabled])",
476 "a[href]",
477 "input:not([disabled])",
478 "select:not([disabled])",
479 "textarea:not([disabled])",
480 '[tabindex]:not([tabindex="-1"])',
481 ].join(", ");
482
483 return Array.from(
484 container.querySelectorAll<HTMLElement>(focusableSelectors)
485 ).filter((el) => el.offsetParent !== null); // Filter out hidden elements
486}
487
488/**
489 * Handle keyboard navigation within modal (focus trap)

Callers 1

handleModalKeydownFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected