Skip to content
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

Closed
wants to merge 38 commits into from
Closed

fix: improves form timer (old) #4340

wants to merge 38 commits into from

Conversation

thiessenp-cds
Copy link
Contributor

@thiessenp-cds thiessenp-cds commented Sep 26, 2024

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).

@thiessenp-cds thiessenp-cds linked an issue Sep 26, 2024 that may be closed by this pull request
3 tasks
Copy link
Contributor

@thiessenp-cds thiessenp-cds marked this pull request as ready for review October 7, 2024 12:43
@thiessenp-cds thiessenp-cds requested review from ShadeWyrm and removed request for ShadeWyrm October 7, 2024 17:34
@Abi-Nada
Copy link

Abi-Nada commented Oct 8, 2024

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?)

@thiessenp-cds thiessenp-cds marked this pull request as ready for review October 15, 2024 14:00
lib/formContext.ts Outdated Show resolved Hide resolved
@bryan-robitaille bryan-robitaille changed the base branch from develop to main October 15, 2024 18:45
lib/formContext.ts Outdated Show resolved Hide resolved
@@ -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");
Copy link
Contributor Author

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

@thiessenp-cds thiessenp-cds changed the title fix: improves form timer fix: improves form timer (old) Oct 21, 2024
@thiessenp-cds thiessenp-cds marked this pull request as draft October 21, 2024 16:09
@thiessenp-cds
Copy link
Contributor Author

Moved to this PR that takes a simpler approach #4437

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Form timer not working
4 participants