Users had to manually scroll up to see the top of multi-step application forms after clicking the "Next" button. This created a poor user experience as users would lose context of where they were in the form.
Added automatic smooth scroll-to-top behavior in all application forms:
- ✅ Hacker Application (
/hack/[event_id]/hacker-application) - ✅ Mentor Application (
/hack/[event_id]/mentor-application) - ✅ Volunteer Application (
/hack/[event_id]/volunteer-application) - ✅ Sponsor Application (
/hack/[event_id]/sponsor-application) - ✅ Judge Application (
/hack/[event_id]/judge-application)
For Navigation:
const handleNext = () => {
// ... validation logic ...
if (activeStep === steps.length - 1) {
handleSubmit();
} else {
setActiveStep(prev => prev + 1);
// Scroll to top of form for better UX
if (formRef?.current) {
formRef.current.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
};
const handleBack = () => {
setActiveStep(prev => prev - 1);
// Scroll to top of form for better UX
if (formRef?.current) {
formRef.current.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
};For Validation Errors (Hacker Application):
const setErrorAndScroll = (errorMessage) => {
setError(errorMessage);
if (formRef?.current) {
formRef.current.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
};Before:
- User fills out form step
- Clicks "Next" button
- Form advances to next step
- User has to manually scroll up to see the new form content
- User loses context and has to reorient themselves
After:
- User fills out form step
- Clicks "Next" button
- Form advances to next step
- Form automatically scrolls to top with smooth animation
- User immediately sees the new form content without any manual action
- Smooth Animation: Uses
behavior: 'smooth'for pleasant visual transitions - Optimal Positioning: Uses
block: 'start'to position form at the top of viewport - Error Handling: Validation errors also trigger scroll-to-top for better visibility
- Minimal Changes: Leverages existing
formRefreferences for zero breaking changes - Consistent Implementation: Same behavior across all application forms
- All existing tests continue to pass (34/34 tests successful)
- Added comprehensive test suite to verify scroll behavior implementation
- Manual testing confirms smooth scroll behavior works as expected
- Properly formatted with Prettier
- React hook dependencies correctly maintained
- ESLint warnings addressed where applicable
- No breaking changes to existing functionality
This fix significantly improves the user experience of the application process, making the multi-step forms much more intuitive and user-friendly.