diff --git a/src/components/BookingSection.tsx b/src/components/BookingSection.tsx index 5dfb736..37b5302 100644 --- a/src/components/BookingSection.tsx +++ b/src/components/BookingSection.tsx @@ -45,6 +45,7 @@ const BookingSection = () => { const [showCountryDropdown, setShowCountryDropdown] = useState(false); const countryDropdownRef = useRef(null); const countryInputRef = useRef(null); + const sectionRef = useRef(null); // Generate unique requestId on component mount useEffect(() => { const uniqueId = `REQ-${Date.now()}-${Math.floor(Math.random() * 10000)}`; @@ -107,6 +108,13 @@ const BookingSection = () => { return () => document.removeEventListener('mousedown', handleClickOutside); }, [showCountryDropdown]); + // Ensure the booking section stays in view when status changes (e.g., after submit) + useEffect(() => { + if (status === "success" || status === "error") { + sectionRef.current?.scrollIntoView({ behavior: "smooth", block: "start" }); + } + }, [status]); + const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setErrors({}); @@ -141,7 +149,7 @@ const BookingSection = () => { if (status === "success") { return ( -
+
{ } return ( -
+