feat: make form state persistent between route changes#146
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements form state persistence across route changes by introducing a FormPersistenceState that maintains draft data for both BTC and Baby staking forms. The solution uses the onChange prop on Form components to continuously save form data to React state.
- Adds FormPersistenceState context to store draft form data in memory
- Modifies Tabs component to support keepMounted prop for maintaining component state
- Updates forms to use defaultValues from persisted drafts and save changes via onChange handlers
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| services/simple-staking/src/ui/common/state/index.tsx | Registers FormPersistenceState in state provider list |
| services/simple-staking/src/ui/common/state/FormPersistenceState.tsx | New state context for persisting BTC and Baby staking form drafts |
| services/simple-staking/src/ui/common/page.tsx | Enables keepMounted prop on main Tabs component |
| services/simple-staking/src/ui/common/components/Tabs/Tabs.tsx | Adds keepMounted option to render all tab content with visibility control |
| services/simple-staking/src/ui/common/components/Staking/FeeModal/index.tsx | Adds currentFeeRate prop to initialize modal state based on current form values |
| services/simple-staking/src/ui/common/components/Multistaking/MultistakingForm/StakingFeesSection.tsx | Removes automatic fee rate initialization and passes current rate to FeeModal |
| services/simple-staking/src/ui/common/components/Multistaking/MultistakingForm/MultistakingForm.tsx | Integrates form persistence with defaultValues and onChange handler |
| services/simple-staking/src/ui/baby/widgets/StakingForm/index.tsx | Adds StakingFormFields type and integrates form persistence for Baby staking |
| services/simple-staking/src/ui/baby/layout.tsx | Enables keepMounted for Baby staking tabs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
gbarkhatov
previously approved these changes
Sep 9, 2025
Contributor
gbarkhatov
left a comment
There was a problem hiding this comment.
Approved with minor suggestions, @jeremy-babylonlabs @jrwbabylonlab @jonybur please also check
jonybur
approved these changes
Sep 11, 2025
This file contains hidden or 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
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.
continuation of babylonlabs-io/simple-staking#1525
i realized we can use the
onChangeprop onFormcomponent, so changed the logic from functional component to current version.solved the type inconsistency by introducing a new type
StakingFormFields. this is required because we can't directly useFormDatasince theStakingFormexpects validatorAddresses.