Abstract onboarding wizard into reusable FormWizard#663
Conversation
Extract the ~400-line OnboardingForm wizard into a reusable form.Wizard and form.WizardStep component system that integrates with TanStack Form's formComponents registry. This enables multi-step wizards for onboarding, club match, club creation, and event creation forms. Key changes: - Create FormWizard/ directory with types, context, and components - Register Wizard and WizardStep as formComponents in form.ts - Fix validation to only block forward navigation (not backward) - Auto-advance to finish step after successful form submission - Rewrite OnboardingForm from ~400 lines to ~260 lines - Delete OnboardingFormStep (content moved inline to WizardStep children) Closes #588
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@Isoscelestial, Hey Isaac wanted to follow up on this, can you check it when you get the chance? |
Isoscelestial
left a comment
There was a problem hiding this comment.
I did a quick look through, I like how it's looking so far! After you fix these things, I'll do another more in-depth review.
Co-authored-by: Isoscelestial <isoscelestial@gmail.com>
Moved startStep and finishStep from Wizard props into WizardStep children using startStep and finishStep boolean props, so the API is consistent with how body steps are declared. Restored type safety on StepConfig using a discriminated union so start and finish variants cannot have fields. Fixed the Continue button on the finish screen not working, and made the wizard wait for the API call to finish before advancing to the finish step. Fixed date picker dark mode background from neutral-900 to neutral-800.
Isoscelestial
left a comment
There was a problem hiding this comment.
Looking good, love to see it functional! Sorry that I'm requesting a lot of changes...
|
Adding a note here to copy these changes over to Notebook after merge. |
|
Resolved all FormWizard-related threads since we're taking a different approach: fixing the two real bugs directly in What's fixed (on
Left unresolved: The thread about changing The FormWizard abstraction can be revisited when a second wizard consumer actually exists (club creation, event creation, etc.), at which point the real API surface will be clearer. |
Co-authored-by: Isoscelestial <isoscyoung@gmail.com>
You already made the full abstraction. At this point, we are just fixing bugs and code quality issues. I am unresolving all the threads so that they can be fixed. If you'd like help with some of the threads, I'd be more than happy to tackle some of them!
Not sure where this branch name came from. If your AI tends to hallucinate, I ask that you at the very least double check your code and comments before sending them to be reviewed.
I'd like these changes to be made now, as we've figured out a solution and are just waiting for the code to be written. Related PR: UTDNebula/utd-notebook#183
As we discussed earlier, we are planning to have a "second wizard consumer" by using this abstracted system with the club matching form, the club creation form, and event creation form. |
… begin refactoring onboarding form and schema
…rd step options, wizard actions, improved button handling, add support for conditional steps
…t crash when no enabled steps
…y rerenders, fix hydration issues
…default export for wizard context
…more options and actions, allow jumping to disabled steps, more flexible CSS
|
So I may have gone overboard with my additions 💀 I edited this PR's initial comment to document my changes. But yeah @SinhSinhAn your abstraction absolutely works, I just wanted to make the actual wizard more robust and customizable. For other people reviewing this PR, you can just test the |
|
Bro this is your PR now 💀💀 Congrats and great job |
Closes #588
Summary
Mostly internal changes that will make things a lot easier to develop in the future.
form.Wizardandform.WizardStepcomponents that any form can use/directory/create) as an exampleHow it works
The wizard registers as a TanStack Form
formComponent, so consumers use it asform.Wizard/form.WizardStep:The wizard renders a consistent UI that consists of: a MUI Stepper, steps with slide transitions, dynamic height, and navigation buttons.
The
FormWizardStepcomponent is NOT rendered normally, asFormWizarduses itschildrenprop to construct the array of steps for handling. Each step also corresponds to Tanstack Form v1.33's new FormGroup for validation; entering an object key that matches your form's schema into the step'snameprop ensures that step's fields are validated correctly, allowing the wizard to handle progression through the stepper and navigation buttons correctly.Example
Files changed
src/components/form/FormWizard/src/components/form/FormWizard.tsxsrc/utils/form.tssrc/components/getting-started/OnboardingForm.tsxsrc/components/getting-started/OnboardingFormStep.tsxsrc/app/directory/create/CreateClubForm.tsxsrc/components/form/*.tsxsrc/components/settings/forms/UserInfo.tsxsrc/utils/formSchemas.tssrc/utils/Subscribe.tsxsrc/utils/useIsMounted.ts