diff --git a/app/api/auth/route.ts b/app/api/auth/route.ts index a444bf8..9e0d6a4 100644 --- a/app/api/auth/route.ts +++ b/app/api/auth/route.ts @@ -41,9 +41,12 @@ export async function POST(request: NextRequest) { } if (!isProtected(slug, type)) { - return NextResponse.json({ - error: `${type === 'subpage' ? 'Subpage' : 'Album'} is not password-protected`, - }, { status: 400 }); + return NextResponse.json( + { + error: `${type === 'subpage' ? 'Subpage' : 'Album'} is not password-protected`, + }, + { status: 400 }, + ); } const setCookie = authenticate(slug, password, type); diff --git a/components/Lightbox.tsx b/components/Lightbox.tsx index 115e283..090e88e 100644 --- a/components/Lightbox.tsx +++ b/components/Lightbox.tsx @@ -31,6 +31,7 @@ export function Lightbox({ assets, currentIndex, onClose, onNext, onPrev }: Ligh const { exifData, exifLoading, fetchExif, clearExif } = useExif(); const [imageLoaded, setImageLoaded] = useState(false); const overlayRef = useRef(null); + const closeBtnRef = useRef(null); const current = assets[currentIndex]; const [mounted, setMounted] = useState(false); @@ -40,6 +41,13 @@ export function Lightbox({ assets, currentIndex, onClose, onNext, onPrev }: Ligh setMounted(true); }, []); + // Auto-focus the close button when the modal mounts + useEffect(() => { + if (mounted) { + closeBtnRef.current?.focus(); + } + }, [mounted]); + // Reset EXIF data when switching images; refetch if panel is open useEffect(() => { clearExif(); @@ -109,7 +117,13 @@ export function Lightbox({ assets, currentIndex, onClose, onNext, onPrev }: Ligh aria-label="Image viewer" > {/* Close button */} -