MetaMask / MetaMask/metamask-extension
Improve routing for back button for add wallet modal
@georgewrmarshall is already working on this.
Since Sep 2, 2025.
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
### What is this about?
The ImportSrp component (`ui/pages/multi-srp/import-srp/import-srp.tsx`) currently navigates back to the homepage when using the back button or close button, but it should navigate back to the add wallet modal context when accessed from that flow.
### Scenario
- GIVEN a user is in the add wallet modal flow
- WHEN a user navigates to the ImportSrp page to import a seed phrase
- AND a user clicks the back button or close button
- THEN the user should return to the add wallet modal
- BUT currently the user is taken to the homepage instead
### Design
_No response_
### Technical Details
**Current Implementation:**
In `ui/pages/multi-srp/import-srp/import-srp.tsx` (lines 324-327 and 333-336), both the back button and close button navigate to `DEFAULT_ROUTE`:
```typescript
onClick={() => {
history.push(DEFAULT_ROUTE);
}}
```
**Required Change:**
The navigation logic needs to be context-aware and return to the appropriate previous page based on how the user reached the ImportSrp page. When accessed from the add wallet modal, it should return to that modal instead of the homepage.
**Files to modify:**
- `ui/pages/multi-srp/import-srp/import-srp.tsx`
- Potentially routing logic related to the add wallet modal flow
### Threat Modeling Framework
- **What are we working on?** Fixing navigation flow to improve user experience by maintaining proper context when navigating between modal flows
- **What can go wrong?** Users could become lost in the navigation flow, leading to confusion and potential abandonment of the add wallet process
- **What are we going to do about it?** Implement context-aware navigation that respects the user's journey through the application
- **Did we do a good job?** Success will be measured by users being able to seamlessly navigate back to the add wallet modal when appropriate
### Acceptance Criteria
- [ ] When accessing ImportSrp from add wallet modal, back/close buttons should return to add wallet modal
- [ ] When accessing ImportSrp from other contexts, back/close buttons should maintain existing behavior
- [ ] Navigation context should be properly maintained throughout the flow
- [ ] No regression in existing ImportSrp functionality
- [ ] Manual testing of both navigation paths
### Stakeholder review needed before the work gets merged
- [x] Engineering (needed in most cases)
- [ ] Design
- [ ] Product
- [x] QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
- [ ] Security
- [ ] Legal
- [ ] Marketing
- [ ] Management (please specify)
- [ ] Other (please specify)
### References
- Related PR: https://github.com/MetaMask/metamask-extension/pull/35536
- ImportSrp component: `ui/pages/multi-srp/import-srp/import-srp.tsx`
- Navigation occurs in onClick handlers for back (lines 324-327) and close (lines 333-336) buttons
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.