All files / src/features/sorting SortDoneHeading.tsx

100% Statements 5/5
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 182x                 1x 1x 1x            
"use client";
 
import { useEffect, useRef } from "react";
 
/**
 * The end-of-sort heading takes focus when it appears: the last pair's controls
 * leave with the answer, and focus would otherwise fall to <body> unannounced.
 */
export function SortDoneHeading({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLHeadingElement>(null);
  useEffect(() => ref.current?.focus(), []);
  return (
    <h1 ref={ref} tabIndex={-1} className="font-display text-3xl text-ink focus:outline-hidden">
      {children}
    </h1>
  );
}