-
-
Notifications
You must be signed in to change notification settings - Fork 57
Fix form skip logic #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix form skip logic #349
Conversation
allows for moveForward and moveBackward to get updated values
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Only thing for the future would be to remove some of the unnecessary comments, but nbd.
Bug fix: Stale data from form submission impacting skip logic
Issue:
Interview navigation functions (
moveForward
andmoveBackward
) were using stale values ofnextValidStageIndex
andpreviousValidStageIndex
due to closures. When these indexes were updated during form submission in thebeforeNext
handler, the navigation functions weren't receiving the updated values. This resulted in behavior where if form data impacted skip logic, the skip logic wasn't working correctly.Solution:
useRef
to store index values as refsuseEffect
hooks to update these refs whenever indexes changemoveForward
andmoveBackward
to use current ref values for updating session progress and stage instead of closure-captured variablesOther changes:
This investigation also revealed a circular deps issue and duplicate selectors (two duplicate versions of
getStageIndex
). Fixed this by moving some selectors (getActiveSession
,getStageIndex
) to ashared
file and importing from there.