Skip to content

Commit 7eaac6a

Browse files
authored
fix: keyboard pushing screen up during password input (#16898)
<!-- 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** <!-- 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? --> This PR fixes the issue where the keyboard would push screen up instead of overlaying. ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/MUL-321?atlOrigin=eyJpIjoiMDAzNzY3N2IzZGRhNGI2MDgyMTA2MjQyM2Q4ZDY1YTUiLCJwIjoiaiJ9 ## **Manual testing steps** 1. Enable multichain account design 2. Go to account details 3. Click to reveal private key 4. Click on the input and trigger the software keyboard 5. See that the screen is not being pushed up. ## **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/e0d8cb1e-9b1e-49a6-8a25-5124399a97ba ### **After** https://github.com/user-attachments/assets/fe7df495-857b-4be6-b0c0-7fbbc5f579ed <!-- [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.
1 parent 7f25efa commit 7eaac6a

File tree

3 files changed

+16
-45
lines changed

3 files changed

+16
-45
lines changed

app/components/Views/MultichainAccounts/sheets/RevealPrivateKey/RevealPrivateKey.styles.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { StyleSheet } from 'react-native';
33
const styleSheet = () =>
44
StyleSheet.create({
55
container: {
6-
marginBottom: 36,
7-
paddingLeft: 24,
8-
paddingRight: 24,
6+
flex: 1,
97
},
108
});
119

app/components/Views/MultichainAccounts/sheets/RevealPrivateKey/RevealPrivateKey.test.tsx

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
import React from 'react';
22
import { fireEvent } from '@testing-library/react-native';
3-
import { TouchableOpacity } from 'react-native';
43
import { RevealPrivateKey } from './RevealPrivateKey';
54
import { internalAccount1 as mockAccount } from '../../../../../util/test/accountsControllerTestUtils';
65
import { KeyringTypes } from '@metamask/keyring-controller';
76
import { strings } from '../../../../../../locales/i18n';
8-
import { SafeAreaProvider } from 'react-native-safe-area-context';
97
import renderWithProvider from '../../../../../util/test/renderWithProvider';
108
import { backgroundState } from '../../../../../util/test/initial-root-state';
11-
12-
jest.mock('react-native-safe-area-context', () => {
13-
const inset = { top: 0, right: 0, bottom: 0, left: 0 };
14-
const frame = { width: 0, height: 0, x: 0, y: 0 };
15-
return {
16-
SafeAreaProvider: jest.fn().mockImplementation(({ children }) => children),
17-
SafeAreaConsumer: jest
18-
.fn()
19-
.mockImplementation(({ children }) => children(inset)),
20-
useSafeAreaInsets: jest.fn().mockImplementation(() => inset),
21-
useSafeAreaFrame: jest.fn().mockImplementation(() => frame),
22-
};
23-
});
9+
import { SHEET_HEADER_BACK_BUTTON_ID } from '../../../../../component-library/components/Sheet/SheetHeader/SheetHeader.constants';
2410

2511
const mockGoBack = jest.fn();
2612
const mockNavigate = jest.fn();
@@ -82,12 +68,7 @@ const render = () => {
8268
},
8369
},
8470
};
85-
return renderWithProvider(
86-
<SafeAreaProvider>
87-
<RevealPrivateKey />
88-
</SafeAreaProvider>,
89-
{ state: initialState },
90-
);
71+
return renderWithProvider(<RevealPrivateKey />, { state: initialState });
9172
};
9273

9374
describe('RevealPrivateKey', () => {
@@ -123,15 +104,8 @@ describe('RevealPrivateKey', () => {
123104
});
124105

125106
it('navigates back when the back button is pressed', () => {
126-
const rendered = render();
127-
const { root } = rendered;
128-
const touchableOpacities = root.findAllByType(TouchableOpacity);
129-
130-
// Hack to get the button
131-
const backButton = touchableOpacities.find(
132-
(touchable) =>
133-
touchable.props.accessible === true && touchable.props.onPress,
134-
);
107+
const { getByTestId } = render();
108+
const backButton = getByTestId(SHEET_HEADER_BACK_BUTTON_ID);
135109

136110
expect(backButton).toBeTruthy();
137111
if (backButton) {

app/components/Views/MultichainAccounts/sheets/RevealPrivateKey/RevealPrivateKey.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import React from 'react';
22
import { strings } from '../../../../../../locales/i18n';
3-
import BottomSheet from '../../../../../component-library/components/BottomSheets/BottomSheet';
43
import { InternalAccount } from '@metamask/keyring-internal-api';
54
import {
65
ParamListBase,
76
RouteProp,
87
useNavigation,
98
useRoute,
109
} from '@react-navigation/native';
11-
import Text, {
12-
TextVariant,
13-
} from '../../../../../component-library/components/Texts/Text';
14-
import BottomSheetHeader from '../../../../../component-library/components/BottomSheets/BottomSheetHeader';
1510
import { RevealPrivateCredential } from '../../../RevealPrivateCredential';
1611
import { PRIVATE_KEY } from '../../../RevealPrivateCredential/RevealPrivateCredential';
12+
import SheetHeader from '../../../../../component-library/components/Sheet/SheetHeader';
13+
import { SafeAreaView } from 'react-native-safe-area-context';
14+
import styleSheet from './RevealPrivateKey.styles';
15+
import { useStyles } from '../../../../hooks/useStyles';
1716

1817
interface RootNavigationParamList extends ParamListBase {
1918
RevealPrivateKey: {
@@ -27,6 +26,7 @@ type RevealPrivateKeyProp = RouteProp<
2726
>;
2827

2928
export const RevealPrivateKey = () => {
29+
const { styles } = useStyles(styleSheet, {});
3030
const navigation = useNavigation();
3131
const route = useRoute<RevealPrivateKeyProp>();
3232
const { account } = route.params;
@@ -35,12 +35,11 @@ export const RevealPrivateKey = () => {
3535
};
3636

3737
return (
38-
<BottomSheet isFullscreen>
39-
<BottomSheetHeader onBack={handleOnBack}>
40-
<Text variant={TextVariant.HeadingMD}>
41-
{strings('multichain_accounts.reveal_private_key.title')}
42-
</Text>
43-
</BottomSheetHeader>
38+
<SafeAreaView style={styles.container}>
39+
<SheetHeader
40+
onBack={handleOnBack}
41+
title={strings('multichain_accounts.reveal_private_key.title')}
42+
/>
4443
<RevealPrivateCredential
4544
credentialName={PRIVATE_KEY}
4645
navigation={navigation}
@@ -55,6 +54,6 @@ export const RevealPrivateKey = () => {
5554
},
5655
}}
5756
/>
58-
</BottomSheet>
57+
</SafeAreaView>
5958
);
6059
};

0 commit comments

Comments
 (0)