-
Notifications
You must be signed in to change notification settings - Fork 13
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: improves form timer (old) #4340
Conversation
🧪 Review environmenthttps://efavdztlznj6cnqgnn65cpnxf40duhkg.lambda-url.ca-central-1.on.aws/ |
I have a question - is it suppose to calculate the time spent on each required question throughout the entire form, prior to the Review Page? Or is it that you need to hang around the Review Page for a certain amount of time (per each required question) before you can submit? (Asking because when I tested, I waited 10 seconds while filling out each required field. But then when I got to the Review Page, I still had to wait to submit the form?) |
@@ -30,7 +30,9 @@ export const useFormTimer = (): [FormTimerStateType, FormTimerDispatchType] => { | |||
): { canSubmit: boolean; remainingTime: number; timerDelay?: number; timeLock?: number } { | |||
switch (action.type) { | |||
case "START": { | |||
if (!action.timerDelay) throw new Error("Missing timerDelay on start FormTimer action"); |
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.
This should be left as is, since 0 is intentionally the disabled state. So don't use 0 as the default
Moved to this PR that takes a simpler approach #4437 |
Summary | Résumé
Improves the form timer by handling the case of forms with groups. If a form has groups, the delay calculation includes required questions based on the group history. The time a user spends on a form is now also included in the calculation.
This is a high risk PR since it updates forms-forms submission logic.
Test
The form timer should not display in the form-builder Preview. The form timer is only for forms-forms
Groups Form
Create a form with groups and add a few required questions. View the form you created and open the dev console. Reload the form (to restart the timer) and quickly fill in the form, counting the number of required questions. When you get to the Review page, check the console and see if the final delay makes sense.
For example, a form that has 10 required questions and has been view for 5 seconds, should have a delay of
2 + (10 - 5) * 2 = 12 seconds
Note that the countdown begins once the Review page loads. So if you linger on the Review page for e.g. 5 seconds and then click the submit button, count down delay should start at e.g. 7 seconds (with a total delay listed of 12 seconds)
Non-Groups Form
Create a form without groups and add a few required questions. Following the same steps above. The difference is the time a form is viewed is not taken into account (existing behaviour - countdown begins when the single page form is shown).