@@ -5,7 +5,7 @@ import { FaReddit, FaGithub, FaEnvelope } from 'react-icons/fa';
55import Header from '@/components/Header' ;
66import Footer from '@/components/Footer' ;
77import { useScroll } from 'framer-motion' ;
8- import { useState , useEffect } from 'react' ;
8+ import { useState , useEffect , useRef } from 'react' ;
99import { useSearchParams } from 'next/navigation' ;
1010
1111export default function GetInvolvedClientPage ( ) {
@@ -15,12 +15,18 @@ export default function GetInvolvedClientPage() {
1515
1616 const searchParams = useSearchParams ( ) ;
1717 const [ formStatus , setFormStatus ] = useState ( { submitted : false , error : false } ) ;
18+ const contactFormRef = useRef ( null ) ;
1819
1920 useEffect ( ( ) => {
2021 const submitted = searchParams . get ( 'submitted' ) === 'true' ;
2122 const error = searchParams . get ( 'error' ) === 'true' ;
2223 if ( submitted || error ) {
2324 setFormStatus ( { submitted, error } ) ;
25+ // Scroll to the contact form section after a short delay
26+ // to ensure the DOM is updated before the success/error message appears.
27+ setTimeout ( ( ) => {
28+ contactFormRef . current ?. scrollIntoView ( { behavior : 'smooth' , block : 'start' } ) ;
29+ } , 100 ) ;
2430 }
2531 } , [ searchParams ] ) ;
2632
@@ -91,7 +97,7 @@ export default function GetInvolvedClientPage() {
9197 </ div >
9298
9399 { /* Contact Form Section */ }
94- < div id = "contact-us" className = "mt-16 pt-12 border-t border-gray-200 scroll-mt-24" >
100+ < div id = "contact-us" ref = { contactFormRef } className = "mt-16 pt-12 border-t border-gray-200 scroll-mt-24" >
95101 < div className = "text-center" >
96102 < h2 className = "text-3xl font-extrabold text-gray-900 sm:text-4xl" > Contact Us</ h2 >
97103 < p className = "mt-4 max-w-2xl mx-auto text-lg text-gray-600" >
0 commit comments