zerobyte/app/client/hooks/use-scroll-to-form-error.ts
2026-02-18 19:33:58 +01:00

10 lines
297 B
TypeScript

import { useCallback } from "react";
export function useScrollToFormError() {
return useCallback(() => {
setTimeout(() => {
const firstError = document.querySelector("[data-slot='form-message']");
firstError?.scrollIntoView({ behavior: "smooth", block: "center" });
}, 50);
}, []);
}