-
Notifications
You must be signed in to change notification settings - Fork 76
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
LF-4022: [spike] investigate current and desired state for navigation #3158
Merged
18 commits merged into
integration
from
LF-4022-SPIKE-Investigate-current-and-desired-state-for-navigation
Apr 26, 2024
Merged
LF-4022: [spike] investigate current and desired state for navigation #3158
18 commits merged into
integration
from
LF-4022-SPIKE-Investigate-current-and-desired-state-for-navigation
Apr 26, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SayakaOno
reviewed
Apr 2, 2024
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.
Co-authored-by: Sayaka Ono <sayaka.ono.81@gmail.com>
The open state and setter are passed from the new form wrapping component now, but the old forms aren't wrapped by that component yet
Restores PureFinanceTypeSelection's compatibility with the old form flow
16 tasks
94dceed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Examples of proposal of changes for navigation handling throughout webapp.
Example 1: Multistep forms with use of useHookFormPersist
There are several instances of multistep form where:
-
useHookFormPersist
andHookFormPersistProvider
are used to handle back and forth navigation throughout the steps and to preserve the data when navigating.This brings a set of problems:
useHookFormPersist
hook that is hard to debug when issues with navigation occur.The example I used to illustrate my proposal for this is the add expense form, which can be accessed from the Transactions screen by clicking on the "Add" button and choosing "Expense".
Proposal:
4c10a8d2401225d3ba473e92348363d4df9f94e7
in this branch). Fiddling with the history in a complex way to change the default behavior of browser navigation seems like a bad idea both from the user experience and the technical perspective.MultiStepForm
. This component handles displaying the progress bar, title of each step and back and cancel buttons to avoid repetition, and renders the contents for each of the steps in the form. It also calls theuseForm
hook fromreact-hook-form
and preserves the data entered by the user in the form. Each form does not need to calluseForm
but gets passed the form from this parent form component, and can read persisted data or get needed methods from it. Note that there isn't a need to store the persisted data to the Redux store in order for it to be preserved between steps --react-hook-form
already handles this with theshouldUnregister
prop. WhenshouldUnregister
is set to false (which is the default), the data is preserved even if the inputs are unmounted. Use ofuseHookFormPersists
andHookFormPersistProvider
is altogether removed in this example.onGoForward
function available to be able to navigate to the next step from each step contents (this couldn't be abstracted since UI for the navigation from one step to the next differs from one form to the next). We'll only need to worry about calling this function to move the user forward, read the data from the form and handle any interdependecies between steps (in the case of the add expense form, the second step displays different inputs depending on the expense types seleted on the first step) and submit the data on the last step.ClickAwayListener
so that the cancel modal will be prompted when the user tries to navigate away, even if not by clicking directly on the Cancel button.Example 2: Multiple UIs for the same route, using navigation to update component state
This example has now been cherry-picked to a separate branch and can be viewed in PR #3173
In the
CustomSignUp
component, we're using a single route and a single component to display multiple different UIs situationally, but using manual navigations to update the state so that we "emulate" multiple routes and allow the user to go from one step to the previous one when using browser navigation. This is another instance where we have logic that's complex to debug and error prone with the purpose of altering the default browser navigation behavior. Essentially here I think we need to make a decision, just like in the first example -- we either go for a single route showing different steps, or we go for separate URLs for each step, but in both cases we should let the browser navigation behave normally, and in both cases we should avoid the current pattern which is using the navigation state as a replacement for actual state either in components or in Redux.If we go for a single route, user won't be able to navigate back and forth between steps by using the browser, and if we use multiple routes then they'll be able to navigate back and forth freely. In this last case they'll also have feedback that a navigation has occurred and they'll know which step they're at by seeing the URL, as opposed to the current situation where they'll be navigating back and forth multiple times to the same URL which can be confusing. In both cases we should also avoid the current pattern which is using the navigation state as a replacement for actual state either in components or in Redux.
In this branch, I went for the first scenario which is a single route. Some highlights of the change are:
Alternatively we could:
Jira link:
https://lite-farm.atlassian.net/browse/LF-4022
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: