Commit 54c7ee9
authored
fix: MUSD-151: Refactored useNavbar to allow render overrides (MetaMask#24171)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
### Bug
This PR fixes an app crash caused by the mUSD conversion flow.. When
navigating away from the conversion screen, we didn't reject the
transaction (`onReject`) which caused subsequent redirects to the
redesigned confirmations to render the conversion screen and crash due
to missing route params.
### Fix
The mUSD conversion flow now extends `useNavbar` to ensure transactions
are rejected when navigating away (e.g. via back button).
### Changes
- Add render overrides options to `useNavbar` to allow experiences to
customize their confirmations navbars while still inheriting behaviour
(e.g. `onReject` called when clicking back button)
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: fixed mUSD conversion flow not rejecting transactions
when navigating away
## **Related issues**
Fixes: [MUSD-151: Stale mUSD conversion transaction not cleared causing
app crash](https://consensyssoftware.atlassian.net/browse/MUSD-151)
## **Manual testing steps**
```gherkin
Feature: mUSD Conversion Navbar
Scenario: user navigates back from mUSD conversion confirmation
Given user is on the mUSD conversion confirmation screen
When user taps the back button
Then the pending mUSD conversion transaction is rejected
And user returns to the previous screen
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/d178ecdb-e703-44eb-8402-bdbc1daa6be6
### **After**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/a481fc63-50e5-4f38-a103-7086f3df742f
## **Pre-merge author checklist**
- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduces navbar render overrides and migrates mUSD conversion to a
new hook using them, removes old navbar options, updates routes, and
expands tests.
>
> - **Confirmations UI**:
> - **Navbar overrides**: Extend `getNavbar` to accept `overrides`
(`headerTitle`, `headerLeft(onBackPress)`, `headerTitleAlign`,
`headerStyle` merged) with default center alignment.
> - **Hook update**: `useNavbar(title, addBackButton, overrides)` now
forwards overrides;
`getEmptyNavHeader`/`useEmptyNavHeaderForConfirmations` aligned; tests
added for overrides and defaults.
> - **mUSD Conversion**:
> - **New hook**: Add `useMusdConversionNavbar(chainId)` rendering
`MUSD` icon with network `Badge` and a back `ButtonIcon`; passes
`chainId` to `getNetworkImageSource`.
> - **Integration**: `MusdConversionInfo` calls
`useMusdConversionNavbar(outputChainId)` and retains `useAddToken`;
tests added.
> - **Cleanup**: Remove `Navbars/musdNavbarOptions.tsx` and its tests.
> - **Navigation**:
> - Use `useEmptyNavHeaderForConfirmations` for
`Routes.FULL_SCREEN_CONFIRMATIONS.REDESIGNED_CONFIRMATIONS`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9eca8af. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent bf6cec9 commit 54c7ee9
12 files changed
Lines changed: 490 additions & 295 deletions
File tree
- app/components
- UI/Earn
- hooks
- routes
- Views/confirmations
- components
- info/musd-conversion-info
- hooks/ui
Lines changed: 0 additions & 108 deletions
This file was deleted.
This file was deleted.
Lines changed: 127 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
0 commit comments