Skip to content

Commit f19868c

Browse files
authored
style: Update NetworkVerificationInfo styles and tests (MetaMask#22644)
<!-- 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 fixes styling on the dapp add new network screen. <!-- 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 a bug causing improper styling on the dapp add new network screen. ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TMCU-17 ## **Manual testing steps** ```gherkin Feature: Add new network from dapp Scenario: user adds new network from dapp Given user goes to the dapp (ie. chainlist.org) When user clicks Add network button Then the screen has proper styling ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <img width="377" height="761" alt="Screenshot 2025-11-13 at 15 10 07" src="https://github.com/user-attachments/assets/aa32531f-83f6-4abf-82d3-ccbdb2ae44d1" /> <!-- [screenshots/recordings] --> ### **After** <img width="399" height="833" alt="Screenshot 2025-11-14 at 10 11 16" src="https://github.com/user-attachments/assets/4d61c060-1728-4ad6-8cbe-6f127bf87cd2" /> <!-- [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] > Inline network details in NetworkVerificationInfo, simplify styles/layout, and update tests/snapshots accordingly. > > - **UI (NetworkVerificationInfo)**: > - Remove `Accordion`; always render details inline: `Chain ID`, `Display name`, and `Block explorer URL`. > - Simplify layout: add `flex: 1` to `accountCardWrapper`, set `contentContainerStyle` with `paddingBottom: 24`, and remove `onLayout`/max-height logic. > - Keep RPC URL row with optional "Review" tag; show URL with `hideKeyFromUrl`. > - **Styles**: > - Update `NetworkVerificationInfo.styles.ts`: add `flex: 1` to `accountCardWrapper`; define `nestedScrollContent` with bottom padding. > - **Tests/Snapshots**: > - Update snapshots in `NetworkVerificationInfo` and `NetworkModal` to reflect inline details and style changes. > - Remove accordion interaction in tests; adjust test name to "renders chainId as a decimal" and expectations. > - **Cleanup**: > - Remove unused state/imports related to accordion and layout measurement. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e6b74c0. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 4e8a91d commit f19868c

5 files changed

Lines changed: 287 additions & 233 deletions

File tree

app/components/UI/NetworkModal/__snapshots__/index.test.tsx.snap

Lines changed: 92 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -297,23 +297,25 @@ exports[`NetworkDetails renders correctly 1`] = `
297297
</Text>
298298
<RCTScrollView
299299
collapsable={false}
300+
contentContainerStyle={
301+
{
302+
"paddingBottom": 24,
303+
}
304+
}
300305
handlerTag={1}
301306
handlerType="NativeViewGestureHandler"
302307
nestedScrollEnabled={true}
303308
onGestureHandlerEvent={[Function]}
304309
onGestureHandlerStateChange={[Function]}
305-
onLayout={[Function]}
306310
style={
307-
[
308-
{
309-
"borderColor": "#b7bbc8",
310-
"borderRadius": 10,
311-
"borderWidth": 1,
312-
"marginVertical": 16,
313-
"padding": 16,
314-
},
315-
undefined,
316-
]
311+
{
312+
"borderColor": "#b7bbc8",
313+
"borderRadius": 10,
314+
"borderWidth": 1,
315+
"flex": 1,
316+
"marginVertical": 16,
317+
"padding": 16,
318+
}
317319
}
318320
>
319321
<View>
@@ -385,67 +387,92 @@ exports[`NetworkDetails renders correctly 1`] = `
385387
>
386388
https://localhost:8545
387389
</Text>
388-
<TouchableOpacity
389-
activeOpacity={0.5}
390-
onPress={[Function]}
390+
<Text
391+
accessibilityRole="text"
391392
style={
392393
{
393-
"alignItems": "center",
394-
"flexDirection": "row",
395-
"height": 24,
396-
"justifyContent": "center",
394+
"color": "#121314",
395+
"fontFamily": "Geist Medium",
396+
"fontSize": 16,
397+
"letterSpacing": 0,
398+
"lineHeight": 24,
397399
}
398400
}
399-
testID="accordionheader"
400401
>
401-
<Text
402-
accessibilityRole="text"
403-
style={
404-
{
405-
"color": "#4459ff",
406-
"fontFamily": "Geist Regular",
407-
"fontSize": 16,
408-
"letterSpacing": 0,
409-
"lineHeight": 24,
410-
}
402+
Chain ID
403+
</Text>
404+
<Text
405+
accessibilityRole="text"
406+
style={
407+
{
408+
"color": "#121314",
409+
"fontFamily": "Geist Regular",
410+
"fontSize": 16,
411+
"letterSpacing": 0,
412+
"lineHeight": 24,
413+
"marginBottom": 8,
411414
}
412-
testID="accordionheader-title"
413-
>
414-
View details
415-
</Text>
416-
<View
417-
style={
418-
[
419-
{
420-
"marginLeft": 4,
421-
},
422-
{
423-
"transform": [
424-
{
425-
"rotate": "0deg",
426-
},
427-
],
428-
},
429-
]
415+
}
416+
>
417+
1
418+
</Text>
419+
<Text
420+
accessibilityRole="text"
421+
style={
422+
{
423+
"color": "#121314",
424+
"fontFamily": "Geist Medium",
425+
"fontSize": 16,
426+
"letterSpacing": 0,
427+
"lineHeight": 24,
430428
}
431-
testID="accordionheader-arrow-icon-animation"
432-
>
433-
<SvgMock
434-
color="#4459ff"
435-
fill="currentColor"
436-
height={16}
437-
name="ArrowDown"
438-
style={
439-
{
440-
"height": 16,
441-
"width": 16,
442-
}
443-
}
444-
testID="accordionheader-arrow-icon"
445-
width={16}
446-
/>
447-
</View>
448-
</TouchableOpacity>
429+
}
430+
>
431+
Display name
432+
</Text>
433+
<Text
434+
accessibilityRole="text"
435+
style={
436+
{
437+
"color": "#121314",
438+
"fontFamily": "Geist Regular",
439+
"fontSize": 16,
440+
"letterSpacing": 0,
441+
"lineHeight": 24,
442+
"marginBottom": 8,
443+
}
444+
}
445+
>
446+
Test Network
447+
</Text>
448+
<Text
449+
accessibilityRole="text"
450+
style={
451+
{
452+
"color": "#121314",
453+
"fontFamily": "Geist Medium",
454+
"fontSize": 16,
455+
"letterSpacing": 0,
456+
"lineHeight": 24,
457+
}
458+
}
459+
>
460+
Block explorer URL
461+
</Text>
462+
<Text
463+
accessibilityRole="text"
464+
style={
465+
{
466+
"color": "#121314",
467+
"fontFamily": "Geist Regular",
468+
"fontSize": 16,
469+
"letterSpacing": 0,
470+
"lineHeight": 24,
471+
}
472+
}
473+
>
474+
https://test.com
475+
</Text>
449476
</View>
450477
</RCTScrollView>
451478
</View>

app/components/UI/NetworkVerificationInfo/NetworkVerificationInfo.styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const styleSheet = (params: { theme: Theme }) => {
1616
paddingHorizontal: 16,
1717
},
1818
accountCardWrapper: {
19+
flex: 1,
1920
borderWidth: 1,
2021
borderColor: colors.border.default,
2122
borderRadius: 10,

app/components/UI/NetworkVerificationInfo/NetworkVerificationInfo.test.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import NetworkVerificationInfo from './NetworkVerificationInfo';
3-
import { render, fireEvent } from '@testing-library/react-native';
3+
import { render } from '@testing-library/react-native';
44
import { BannerAlertSeverity } from '../../../component-library/components/Banners/Banner';
55
import { strings } from '../../../../locales/i18n';
66
import { useSelector } from 'react-redux';
@@ -128,8 +128,9 @@ describe('NetworkVerificationInfo', () => {
128128
).toThrow('Unable to find an element with text');
129129
});
130130

131-
it('should render chainId as a decimal', () => {
131+
it('renders chainId as a decimal', () => {
132132
(useSelector as jest.Mock).mockReturnValue(true);
133+
133134
const { getByText } = render(
134135
<NetworkVerificationInfo
135136
customNetworkInformation={mockNetworkInfo}
@@ -138,12 +139,6 @@ describe('NetworkVerificationInfo', () => {
138139
/>,
139140
);
140141

141-
// Accordion content is hidden by default, so we need to expand it
142-
const accordionButton = getByText(
143-
strings('spend_limit_edition.view_details'),
144-
);
145-
fireEvent.press(accordionButton);
146-
147142
expect(getByText('10')).toBeTruthy();
148143
});
149144

app/components/UI/NetworkVerificationInfo/NetworkVerificationInfo.tsx

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable react/prop-types */
2-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
2+
import React, { useCallback, useEffect, useMemo } from 'react';
33
import { View, Linking, TouchableOpacity } from 'react-native';
44
import { strings } from '../../../../locales/i18n';
55
import { CommonSelectorsIDs } from '../../../../e2e/selectors/Common.selectors';
@@ -10,7 +10,6 @@ import Text, {
1010
import TagColored from '../../../component-library/components-temp/TagColored/TagColored';
1111
import { TagColor } from '../../../component-library/components-temp/TagColored/TagColored.types';
1212
import PickerNetwork from '../../../component-library/components/Pickers/PickerNetwork';
13-
import Accordion from '../../../component-library/components/Accordions/Accordion';
1413
import Icon, {
1514
IconName,
1615
IconSize,
@@ -66,10 +65,6 @@ const NetworkVerificationInfo = ({
6665
isCustomNetwork?: boolean;
6766
isNetworkRpcUpdate?: boolean;
6867
}) => {
69-
const [networkInfoMaxHeight, setNetworkInfoMaxHeight] = useState<
70-
number | null
71-
>(null);
72-
const [networkDetailsExpanded, setNetworkDetailsExpanded] = useState(false);
7368
const { styles } = useStyles(styleSheet, {});
7469
const safeChainsListValidationEnabled = useSelector(
7570
selectUseSafeChainsListValidation,
@@ -203,36 +198,20 @@ const NetworkVerificationInfo = ({
203198
const renderNetworkInfo = () => (
204199
<ScrollView
205200
nestedScrollEnabled
206-
style={[
207-
styles.accountCardWrapper,
208-
networkInfoMaxHeight ? { maxHeight: networkInfoMaxHeight } : undefined,
209-
]}
210-
onLayout={(event) => {
211-
if (!networkInfoMaxHeight) {
212-
setNetworkInfoMaxHeight(event.nativeEvent.layout.height);
213-
}
214-
}}
215-
contentContainerStyle={
216-
networkDetailsExpanded ? styles.nestedScrollContent : undefined
217-
}
201+
style={styles.accountCardWrapper}
202+
contentContainerStyle={styles.nestedScrollContent}
218203
>
219204
{renderCurrencySymbol()}
220205
{renderNetworkRpcUrlLabel()}
221206
<Text style={styles.textSection}>
222207
{hideKeyFromUrl(customNetworkInformation.rpcUrl)}
223208
</Text>
224-
225-
<Accordion
226-
title={strings('spend_limit_edition.view_details')}
227-
onPress={() => setNetworkDetailsExpanded(!networkDetailsExpanded)}
228-
>
229-
{renderChainId()}
230-
{renderNetworkDisplayName()}
231-
<Text variant={TextVariant.BodyMDMedium}>
232-
{strings('add_custom_network.block_explorer_url')}
233-
</Text>
234-
<Text>{customNetworkInformation.blockExplorerUrl}</Text>
235-
</Accordion>
209+
{renderChainId()}
210+
{renderNetworkDisplayName()}
211+
<Text variant={TextVariant.BodyMDMedium}>
212+
{strings('add_custom_network.block_explorer_url')}
213+
</Text>
214+
<Text>{customNetworkInformation.blockExplorerUrl}</Text>
236215
</ScrollView>
237216
);
238217

0 commit comments

Comments
 (0)