Skip to content

Commit edaf5b3

Browse files
authored
fix(confirmations): prevent Perps withdraw clipping on Android cp-7.75.0 (#29434)
## **Description** Fixes an Android layout issue where the Perps Withdraw confirmation keypad bottom row and the final Withdraw button could be clipped behind the system navigation area. The fix keeps the shared full-screen confirmation layout intact, ensures the confirmation ScrollView fills its safe-area container, and applies extra Android bottom spacing only to the Perps Withdraw bottom block. ## **Changelog** CHANGELOG entry: Fixed Perps Withdraw on Android so the keypad and Withdraw button remain fully visible. ## **Related issues** Fixes: #29363 ## **Manual testing steps** ~~~gherkin Feature: Perps Withdraw Android layout Scenario: Perps Withdraw keypad is fully visible on Android Given I am on the Perps Withdraw confirmation When the amount keyboard is visible Then the bottom keypad row is fully visible above the Android navigation bar Scenario: Perps Withdraw button is fully visible on Android Given I am on the Perps Withdraw confirmation When I enter an amount and continue past the keyboard Then the Withdraw button is fully visible with bottom spacing Scenario: Other deposit flows are not regressed Given I open Perps Deposit and Predict Deposit confirmations Then their keyboards remain fully visible and keep expected bottom spacing ~~~ ## **Screenshots/Recordings** ### **Before** Android Perps Withdraw keypad / Withdraw button clipped behind the system navigation area. ### **After** Android Perps Withdraw keypad and Withdraw button fully visible. Verified on Pixel 6 and Pixel 10 Pro XL. ## **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. #### Performance checks (if applicable) - [x] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [x] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [x] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). ## **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] > **Low Risk** > Small, opt-in styling change scoped to Perps Withdraw (and Android-only) with added unit tests; minimal risk beyond potential minor layout spacing differences on affected screens. > > **Overview** > Prevents Perps Withdraw confirmation UI from clipping behind the Android gesture/navigation bar by adding an opt-in `hasExtraBottomPadding` prop to `CustomAmountInfo` and applying a 56dp `paddingBottom` to the bottom block *only on Android*. > > `PerpsWithdrawInfo` now enables this padding, and new test IDs plus unit tests cover the platform-conditional styling and prop behavior to avoid iOS/layout regressions. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dd5c508. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
1 parent 770afdb commit edaf5b3

7 files changed

Lines changed: 124 additions & 2 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Platform } from 'react-native';
2+
import { Theme } from '../../../../../../util/theme/models';
3+
import styleSheet from './custom-amount-info.styles';
4+
5+
describe('custom-amount-info.styles', () => {
6+
const originalPlatformOS = Platform.OS;
7+
8+
afterEach(() => {
9+
Object.defineProperty(Platform, 'OS', {
10+
value: originalPlatformOS,
11+
writable: true,
12+
});
13+
});
14+
15+
describe('extraBottomPadding', () => {
16+
it('applies 56dp paddingBottom on Android', () => {
17+
Object.defineProperty(Platform, 'OS', {
18+
value: 'android',
19+
writable: true,
20+
});
21+
22+
const styles = styleSheet({ theme: {} as Theme });
23+
24+
expect(styles.extraBottomPadding.paddingBottom).toBe(56);
25+
});
26+
27+
it('applies 0 paddingBottom on iOS so the iOS layout is unchanged', () => {
28+
Object.defineProperty(Platform, 'OS', {
29+
value: 'ios',
30+
writable: true,
31+
});
32+
33+
const styles = styleSheet({ theme: {} as Theme });
34+
35+
expect(styles.extraBottomPadding.paddingBottom).toBe(0);
36+
});
37+
});
38+
});

app/components/Views/confirmations/components/info/custom-amount-info/custom-amount-info.styles.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { StyleSheet } from 'react-native';
1+
import { Platform, StyleSheet } from 'react-native';
22
import { Theme } from '../../../../../../util/theme/models';
33

4+
const EXTRA_ANDROID_BOTTOM_PADDING = 56;
5+
46
const styleSheet = (_params: { theme: Theme }) =>
57
StyleSheet.create({
68
container: {
@@ -16,6 +18,11 @@ const styleSheet = (_params: { theme: Theme }) =>
1618
gap: 14,
1719
},
1820

21+
extraBottomPadding: {
22+
paddingBottom:
23+
Platform.OS === 'android' ? EXTRA_ANDROID_BOTTOM_PADDING : 0,
24+
},
25+
1926
disabledButton: {
2027
opacity: 0.5,
2128
},

app/components/Views/confirmations/components/info/custom-amount-info/custom-amount-info.test.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ import { strings } from '../../../../../../../locales/i18n';
3232
import { Hex } from '@metamask/utils';
3333
import { TransactionPayRequiredToken } from '@metamask/transaction-pay-controller';
3434
import { fireEvent } from '@testing-library/react-native';
35+
import { Platform } from 'react-native';
3536
import { TransactionType } from '@metamask/transaction-controller';
37+
import { CustomAmountInfoTestIds } from './custom-amount-info.testIds';
3638
import { useTransactionConfirm } from '../../../hooks/transactions/useTransactionConfirm';
3739
import { useTransactionMetadataRequest } from '../../../hooks/transactions/useTransactionMetadataRequest';
3840
import { useTokenFiatRates } from '../../../hooks/tokens/useTokenFiatRates';
@@ -318,6 +320,56 @@ describe('CustomAmountInfo', () => {
318320
expect(getByTestId('deposit-keyboard')).toBeDefined();
319321
});
320322

323+
describe('hasExtraBottomPadding', () => {
324+
const originalPlatformOS = Platform.OS;
325+
326+
afterEach(() => {
327+
Object.defineProperty(Platform, 'OS', {
328+
value: originalPlatformOS,
329+
writable: true,
330+
});
331+
});
332+
333+
it('applies 56dp paddingBottom to the bottom block on Android when hasExtraBottomPadding is true', () => {
334+
Object.defineProperty(Platform, 'OS', {
335+
value: 'android',
336+
writable: true,
337+
});
338+
339+
const { getByTestId } = render({ hasExtraBottomPadding: true });
340+
341+
expect(getByTestId(CustomAmountInfoTestIds.BOTTOM_BLOCK)).toHaveStyle({
342+
paddingBottom: 56,
343+
});
344+
});
345+
346+
it('does not apply paddingBottom to the bottom block when hasExtraBottomPadding is false (Android)', () => {
347+
Object.defineProperty(Platform, 'OS', {
348+
value: 'android',
349+
writable: true,
350+
});
351+
352+
const { getByTestId } = render({ hasExtraBottomPadding: false });
353+
354+
expect(getByTestId(CustomAmountInfoTestIds.BOTTOM_BLOCK)).not.toHaveStyle(
355+
{ paddingBottom: 56 },
356+
);
357+
});
358+
359+
it('does not apply paddingBottom to the bottom block on iOS even when hasExtraBottomPadding is true', () => {
360+
Object.defineProperty(Platform, 'OS', {
361+
value: 'ios',
362+
writable: true,
363+
});
364+
365+
const { getByTestId } = render({ hasExtraBottomPadding: true });
366+
367+
expect(getByTestId(CustomAmountInfoTestIds.BOTTOM_BLOCK)).not.toHaveStyle(
368+
{ paddingBottom: 56 },
369+
);
370+
});
371+
});
372+
321373
it('renders footerText when passed in', () => {
322374
const hint = 'Test footer text';
323375
const { getByText } = render({ footerText: hint });
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const CustomAmountInfoTestIds = {
2+
BOTTOM_BLOCK: 'custom-amount-info-bottom-block',
3+
} as const;

app/components/Views/confirmations/components/info/custom-amount-info/custom-amount-info.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { useTransactionPayToken } from '../../../hooks/pay/useTransactionPayToke
6666
import { getNativeTokenAddress } from '@metamask/assets-controllers';
6767
import PayAccountSelector from '../../PayAccountSelector';
6868
import { useTransactionAccountOverride } from '../../../hooks/transactions/useTransactionAccountOverride';
69+
import { CustomAmountInfoTestIds } from './custom-amount-info.testIds';
6970

7071
export interface CustomAmountInfoProps {
7172
children?: ReactNode;
@@ -90,6 +91,12 @@ export interface CustomAmountInfoProps {
9091
* When true, the account selector is shown.
9192
*/
9293
supportAccountSelection?: boolean;
94+
/**
95+
* Adds bottom space to the bottom block (rows + keyboard/confirm button).
96+
* Used by Perps Withdraw on Android, where this screen has one extra
97+
* balance line and otherwise clips behind the system gesture bar.
98+
*/
99+
hasExtraBottomPadding?: boolean;
93100
}
94101

95102
export const CustomAmountInfo: React.FC<CustomAmountInfoProps> = memo(
@@ -99,6 +106,7 @@ export const CustomAmountInfo: React.FC<CustomAmountInfoProps> = memo(
99106
disableConfirm,
100107
disablePay,
101108
hasMax,
109+
hasExtraBottomPadding,
102110
onAmountSubmit,
103111
hidePayTokenAmount,
104112
preferredToken,
@@ -208,7 +216,11 @@ export const CustomAmountInfo: React.FC<CustomAmountInfoProps> = memo(
208216
)}
209217
{!hidePayTokenAmount && children}
210218
</Box>
211-
<Box gap={16}>
219+
<Box
220+
gap={16}
221+
testID={CustomAmountInfoTestIds.BOTTOM_BLOCK}
222+
style={hasExtraBottomPadding && styles.extraBottomPadding}
223+
>
212224
<AlertMessage alertMessage={alertMessage} />
213225
{supportAccountSelection && <PayAccountSelector />}
214226
{!isResultReady && disablePay !== true && hasTokens && <PayWithRow />}

app/components/Views/confirmations/components/info/perps-withdraw-info/perps-withdraw-info.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,13 @@ describe('PerpsWithdrawInfo', () => {
8080
expect.anything(),
8181
);
8282
});
83+
84+
it('passes hasExtraBottomPadding=true to CustomAmountInfo to clear the Android gesture bar', () => {
85+
render(<PerpsWithdrawInfo />);
86+
87+
expect(mockCustomAmountInfo).toHaveBeenCalledWith(
88+
expect.objectContaining({ hasExtraBottomPadding: true }),
89+
expect.anything(),
90+
);
91+
});
8392
});

app/components/Views/confirmations/components/info/perps-withdraw-info/perps-withdraw-info.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export function PerpsWithdrawInfo() {
2626
currency={PERPS_CURRENCY}
2727
disablePay={!canSelectWithdrawToken}
2828
hasMax
29+
hasExtraBottomPadding
2930
>
3031
<PerpsWithdrawBalance />
3132
</CustomAmountInfo>

0 commit comments

Comments
 (0)