Skip to content

Commit 07ecc3d

Browse files
feat: show back button for settings inner page on extended mode (#37486)
<!-- 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** This PR adds back button to inner pages inside settings. Some pages in Settings have inner pages like - Contacts > View/Edit contact - Security & privacy > Backup SRP - Security & privacy > Change password - Transaction shield > Claims Add/View/List Currently there is no way to go back to prev pages on `extended mode`. User has to click on the left menu again or go back from the start every time. <!-- 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? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37486?quickstart=1) ## **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: Add back button to Settings inner pages ## **Related issues** Fixes: ## **Manual testing steps** 1. Login to metamask and make sure you are in `extended mode` 2. Browse Menu > Settings 3. Explore pages like Contact, Security Settings (Backup SRP, Change password), and Transaction Shield (needs subscription) 4. There should be back button on each inner pages. The back route should be same with the redirections on popup mode. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/3cb3bbd0-ad42-4792-a91f-6a9cc885ab20 <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/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-extension/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] > Adds a back button to the settings subheader for inner pages and wires `backRoute`/`navigate` to handle navigation. > > - **Settings UI (`ui/pages/settings/settings.component.js`)** > - Add subheader back button on inner pages: renders `ButtonIcon` with `IconName.ArrowLeft` when `backRoute !== > `SETTINGS_ROUTE` and not on `NETWORKS_ROUTE`; clicking navigates to `backRoute`. > - Props: include `backRoute` and `navigate` (PropTypes updated) to support back navigation. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 4bd2a55. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 4408e92 commit 07ecc3d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ui/pages/settings/settings.component.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ class SettingsPage extends PureComponent {
323323
isAddressEntryPage,
324324
pathnameI18nKey,
325325
addressName,
326+
backRoute,
327+
navigate,
326328
} = this.props;
327329
let subheaderText;
328330

@@ -334,6 +336,9 @@ class SettingsPage extends PureComponent {
334336
subheaderText = t(pathnameI18nKey || 'general');
335337
}
336338

339+
// Show back button only on inner pages of the settings page
340+
const showBackButton = backRoute !== SETTINGS_ROUTE;
341+
337342
return (
338343
!currentPath.startsWith(NETWORKS_ROUTE) && (
339344
<Box
@@ -345,6 +350,14 @@ class SettingsPage extends PureComponent {
345350
flexDirection={FlexDirection.Row}
346351
alignItems={AlignItems.center}
347352
>
353+
{showBackButton && (
354+
<ButtonIcon
355+
iconName={IconName.ArrowLeft}
356+
onClick={() => navigate(backRoute)}
357+
marginRight={2}
358+
size={ButtonIconSize.Md}
359+
/>
360+
)}
348361
<Text variant={TextVariant.headingSm}>{subheaderText}</Text>
349362
{isAddressEntryPage && (
350363
<div className="settings-page__subheader--break">

0 commit comments

Comments
 (0)