Skip to documentation

Design system / Sources & standards

Current repository source

useMemberDirectoryFocus.ts

src/components/members/useMemberDirectoryFocus.ts

This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.

"use client";

import { useEffect, useRef, type RefObject } from "react";

/** Recover lost row focus without replacing Radix's modal focus management. */
export function useMemberDirectoryFocus(open: boolean, entries: readonly unknown[], headingRef?: RefObject<HTMLHeadingElement | null>) {
  const fallbackTitleRef = useRef<HTMLHeadingElement>(null);
  const titleRef = headingRef ?? fallbackTitleRef;
  useEffect(() => {
    if (open && document.activeElement === document.body) titleRef.current?.focus();
  }, [open, entries, titleRef]);
  return titleRef;
}
All sources and standards
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.