Skip to content
2 changes: 1 addition & 1 deletion test/e2e/tests/custom-rpc-history.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Custom RPC history', function () {
'.networks-tab__add-network-form-footer .btn-primary',
);

await driver.findElement({ text: networkName, tag: 'span' });
await driver.findElement({ text: networkName, tag: 'h6' });
},
);
});
Expand Down
9 changes: 0 additions & 9 deletions test/e2e/tests/onboarding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,6 @@ describe('MetaMask onboarding @no-mmi', function () {
);
await driver.clickElement({ text: 'Done', tag: 'button' });

// After login, check that notification message for added network is displayed
const notificationMessage = `“${networkName}” was successfully added!`;
const networkNotification = await driver.isElementPresent({
css: '[class*="actionable-message__message"]',
text: notificationMessage,
});
assert.equal(networkNotification, true);
await driver.clickElement({ text: 'Dismiss', tag: 'h6' });

// Check localhost 8546 is selected and its balance value is correct
await driver.findElement({
css: '[data-testid="network-display"]',
Expand Down
1 change: 1 addition & 0 deletions ui/pages/onboarding-flow/add-network-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function AddNetworkModal() {
<NetworksForm
addNewNetwork
restrictHeight
setActiveOnSubmit
networksToRender={[]}
cancelCallback={closeCallback}
submitCallback={closeCallback}
Expand Down
23 changes: 12 additions & 11 deletions ui/pages/settings/networks-tab/networks-form/networks-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const prefixChainId = (chainId) => {

const NetworksForm = ({
addNewNetwork,
setActiveOnSubmit = false,
restrictHeight,
isCurrentRpcTarget,
networksToRender,
Expand Down Expand Up @@ -605,20 +606,11 @@ const NetworksForm = ({
},
},
{
setActive: true,
setActive: setActiveOnSubmit,
source: MetaMetricsNetworkEventSource.CustomNetworkForm,
},
),
);
}
if (addNewNetwork) {
dispatch(
setNewNetworkAdded({
nickname: networkName,
networkConfigurationId,
}),
);

trackEvent({
event: MetaMetricsEventName.CustomNetworkAdded,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This event is only called now when a network is added, not when an existing network is edited.

category: MetaMetricsEventCategory.Network,
Expand All @@ -631,9 +623,17 @@ const NetworksForm = ({
token_symbol: ticker,
},
});
}

submitCallback?.();
if (addNewNetwork && !setActiveOnSubmit) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If setActiveOnSubmit is true we switch to the network immediately so we should not show a modal prompting the user to switch to the newly added network (as happens when setNewNetworkAdded action is called.

dispatch(
setNewNetworkAdded({
nickname: networkName,
networkConfigurationId,
}),
);
}
submitCallback?.();
} catch (error) {
setIsSubmitting(false);
throw error;
Expand Down Expand Up @@ -846,6 +846,7 @@ NetworksForm.propTypes = {
cancelCallback: PropTypes.func,
submitCallback: PropTypes.func,
restrictHeight: PropTypes.bool,
setActiveOnSubmit: PropTypes.bool,
};

NetworksForm.defaultProps = {
Expand Down