Skip to content

Commit 2b602f5

Browse files
runway-github[bot]michalconsensyscursoragent
authored
chore(runway): cherry-pick fix(perps): set confirmation header and safe area by navigation source cp-7.64.0 (#25627)
- fix(perps): set confirmation header and safe area by navigation source cp-7.64.0 (#25601) ## **Description** Set confirmation header by navigation source ## **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 Perps confirmation screen so the header is hidden when opening from the one-click order flow and shows a minimal header when opening from other flows. ## **Related issues** Fixes: #25469 ## **Manual testing steps** ```gherkin Feature: Perps confirmation screen header Scenario: user opens confirmation via one-click order (navigateToOrder) Given user is on a Perps market and taps place order (one-click flow) When deposit is confirmed and confirmation screen opens Then the confirmation screen has no header (header: () => null) Scenario: user opens confirmation from another flow Given user reaches RedesignedConfirmations from a path other than navigateToOrder When the confirmation screen is shown Then the screen shows a minimal header (header visible, no left button, empty title) ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <img width="1206" height="2622" alt="Simulator Screenshot - iPhone 17 Pro - 2026-02-03 at 19 47 49" src="https://github.com/user-attachments/assets/8ff43507-5222-426c-a86a-a30a6403baa6" /> <!-- [screenshots/recordings] --> ### **After** <img width="1206" height="2622" alt="Simulator Screenshot - iPhone 17 Pro - 2026-02-03 at 19 46 49" src="https://github.com/user-attachments/assets/d374525a-5732-4049-9c73-da03bd5f29d6" /> <!-- [screenshots/recordings] --> ## **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] > **Medium Risk** > Changes Perps navigation params and `RedesignedConfirmations` screen options, which can affect the confirmation flow’s header visibility and layout. Risk is limited to Perps UI/navigation but could cause regressions if other entry points don’t pass expected params. > > **Overview** > Updates Perps confirmations to **conditionally show/hide the header and safe area** based on the navigation source. > > Adds `CONFIRMATION_HEADER_CONFIG` and a `showPerpsHeader` navigation param; `navigateToOrder` now passes `showPerpsHeader: false` for the deposit-and-trade (one-click) path, while other paths default to a minimal header. > > The Perps stack now derives `RedesignedConfirmations` screen options from route params (and toggles `Confirm`’s `disableSafeArea` accordingly), with types and tests updated to cover the new param behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7d77188. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor <cursoragent@cursor.com> [2bc0e0e](2bc0e0e) Co-authored-by: Michal Szorad <michal.szorad@consensys.net> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d0cc084 commit 2b602f5

5 files changed

Lines changed: 64 additions & 9 deletions

File tree

app/components/UI/Perps/constants/perpsConfig.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ export const ORDER_SLIPPAGE_CONFIG = {
128128
DefaultLimitSlippageBps: 100,
129129
} as const;
130130

131+
/**
132+
* Redesigned confirmations screen header configuration (Perps)
133+
* Controls whether the Perps header is shown when navigating to the confirmation screen
134+
*/
135+
export const CONFIRMATION_HEADER_CONFIG = {
136+
/** Default: show Perps header when opening confirmations from Perps flows */
137+
DefaultShowPerpsHeader: true,
138+
/** Hide Perps header when navigating from deposit-and-trade flow */
139+
ShowPerpsHeaderForDepositAndTrade: false,
140+
} as const;
141+
131142
/**
132143
* Performance optimization constants
133144
* These values control debouncing and throttling for better performance

app/components/UI/Perps/hooks/usePerpsNavigation.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useNavigation } from '@react-navigation/native';
44
import { usePerpsNavigation } from './usePerpsNavigation';
55
import { usePerpsTrading } from './usePerpsTrading';
66
import Routes from '../../../../constants/navigation/Routes';
7+
import { CONFIRMATION_HEADER_CONFIG } from '../constants/perpsConfig';
78

89
jest.mock('@react-navigation/native', () => ({
910
useNavigation: jest.fn(),
@@ -188,7 +189,11 @@ describe('usePerpsNavigation', () => {
188189
expect(mockDepositWithOrder).toHaveBeenCalled();
189190
expect(mockNavigate).toHaveBeenCalledWith(
190191
Routes.FULL_SCREEN_CONFIRMATIONS.REDESIGNED_CONFIRMATIONS,
191-
params,
192+
{
193+
...params,
194+
showPerpsHeader:
195+
CONFIRMATION_HEADER_CONFIG.ShowPerpsHeaderForDepositAndTrade,
196+
},
192197
);
193198
});
194199
});

app/components/UI/Perps/hooks/usePerpsNavigation.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import type { PerpsMarketData, Position, Order } from '../controllers/types';
66
import { usePerpsTrading } from './usePerpsTrading';
77
import Logger from '../../../../util/Logger';
88
import { ensureError } from '../../../../util/errorUtils';
9-
import { PERPS_CONSTANTS } from '../constants/perpsConfig';
9+
import {
10+
PERPS_CONSTANTS,
11+
CONFIRMATION_HEADER_CONFIG,
12+
} from '../constants/perpsConfig';
1013

1114
/**
1215
* Navigation handler result interface
@@ -136,7 +139,11 @@ export const usePerpsNavigation = (): PerpsNavigationHandlers => {
136139
.then(() => {
137140
navigation.navigate(
138141
Routes.FULL_SCREEN_CONFIRMATIONS.REDESIGNED_CONFIRMATIONS,
139-
params,
142+
{
143+
...params,
144+
showPerpsHeader:
145+
CONFIRMATION_HEADER_CONFIG.ShowPerpsHeaderForDepositAndTrade,
146+
},
140147
);
141148
})
142149
.catch((error: unknown) => {

app/components/UI/Perps/routes/index.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createStackNavigator } from '@react-navigation/stack';
22
import React from 'react';
33
import { useSelector } from 'react-redux';
4+
import type { PerpsNavigationParamList } from '../types/navigation';
45
import { SafeAreaView } from 'react-native-safe-area-context';
56
import { StyleSheet } from 'react-native';
67
import { IconName } from '@metamask/design-system-react-native';
@@ -37,8 +38,10 @@ import PerpsStreamBridge from '../components/PerpsStreamBridge';
3738
import { HIP3DebugView } from '../Debug';
3839
import PerpsCrossMarginWarningBottomSheet from '../components/PerpsCrossMarginWarningBottomSheet';
3940
import { useTheme } from '../../../../util/theme';
41+
import { RouteProp, useRoute } from '@react-navigation/native';
42+
import { CONFIRMATION_HEADER_CONFIG } from '../constants/perpsConfig';
4043

41-
const Stack = createStackNavigator();
44+
const Stack = createStackNavigator<PerpsNavigationParamList>();
4245
const ModalStack = createStackNavigator();
4346

4447
const styles = StyleSheet.create({
@@ -47,12 +50,34 @@ const styles = StyleSheet.create({
4750
},
4851
});
4952

50-
const PerpsConfirmScreen = (props: React.ComponentProps<typeof Confirm>) => {
53+
function getRedesignedConfirmationsHeaderOptions({
54+
showPerpsHeader = CONFIRMATION_HEADER_CONFIG.DefaultShowPerpsHeader,
55+
}: PerpsNavigationParamList['RedesignedConfirmations'] = {}) {
56+
return showPerpsHeader
57+
? {
58+
headerLeft: () => null,
59+
headerShown: true,
60+
title: '',
61+
}
62+
: { header: () => null };
63+
}
64+
65+
const PerpsConfirmScreen = (
66+
props: React.ComponentProps<typeof Confirm> & {
67+
route: RouteProp<PerpsNavigationParamList, 'RedesignedConfirmations'>;
68+
},
69+
) => {
5170
const theme = useTheme();
71+
const params =
72+
useRoute<RouteProp<PerpsNavigationParamList, 'RedesignedConfirmations'>>();
73+
const showPerpsHeader =
74+
params?.params?.showPerpsHeader ??
75+
CONFIRMATION_HEADER_CONFIG.DefaultShowPerpsHeader;
76+
5277
return (
5378
<Confirm
5479
{...props}
55-
disableSafeArea
80+
disableSafeArea={!showPerpsHeader}
5681
fullscreenStyle={{
5782
backgroundColor: theme.colors.background.default,
5883
}}
@@ -394,9 +419,9 @@ const PerpsScreenStack = () => {
394419
<Stack.Screen
395420
name={Routes.FULL_SCREEN_CONFIRMATIONS.REDESIGNED_CONFIRMATIONS}
396421
component={PerpsConfirmScreen}
397-
options={{
398-
header: () => null,
399-
}}
422+
options={({ route }) =>
423+
getRedesignedConfirmationsHeaderOptions(route.params)
424+
}
400425
/>
401426
</Stack.Navigator>
402427
</PerpsStreamProvider>

app/components/UI/Perps/types/navigation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export interface PerpsNavigationParamList extends ParamListBase {
2525
orderType?: OrderType;
2626
existingPosition?: Position; // Pass existing position for leverage consistency when adding to position
2727
hideTPSL?: boolean; // Hide TP/SL row when modifying existing position
28+
/** When false, confirmation screen uses header: () => null; when true/undefined uses headerLeft/title options */
29+
showPerpsHeader?: boolean;
2830
};
2931

3032
PerpsOrderSuccess: {
@@ -208,6 +210,11 @@ export interface PerpsNavigationParamList extends ParamListBase {
208210

209211
// Root perps view
210212
Perps: undefined;
213+
214+
/** Params for RedesignedConfirmations when shown in Perps stack (header options) */
215+
RedesignedConfirmations: {
216+
showPerpsHeader?: boolean;
217+
};
211218
}
212219

213220
/**

0 commit comments

Comments
 (0)