Files
zerobyte/app/client/hooks/use-scroll-to-form-error.ts
Nico ca8248b2a0 ui: scroll to error (#541)
* refactor: scroll to first error when submitting a form

* refactor: split file browsers into dedicated components with base

* chore: pr feedbacks
2026-02-18 20:13:09 +01:00

11 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);
}, []);
}