cal-itp / benefits

Transit benefits enrollment, minus the paperwork.
https://docs.calitp.org/benefits
GNU Affero General Public License v3.0
25 stars 9 forks source link

Follow-up on Javascript method to use to redirect user #2119

Closed angela-tran closed 1 month ago

angela-tran commented 1 month ago

I wonder if window.location.replace is the right method here instead? Do we want to support the back button when the user is supposed to wait and not try again immediately?

_Originally posted by @thekaveman in https://github.com/cal-itp/benefits/pull/2089#discussion_r1610342063_

angela-tran commented 1 month ago

We figured out that the strange behavior seen when using window.location.replace was due to the way our phases work. replace is working correctly in removing the current location from the history.

The strange Back button behavior is because when the user is taken back from /enrollment/error to /eligibility/confirm, the confirm view will see that the user is already eligible and redirect them along to the /enrollment. replace then removes /eligibility/confirm from the history, making it so on going "Back" a second time, the user is taken to /eligibility/start. We decided assign is the correct method to use - it gives a consistent experience, and the looping from /enrollment/error to /enrollment is the correct behavior.