From 2393749809449394fcf0f741793b905cbb3ea336 Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Wed, 28 Oct 2020 22:45:08 -0700 Subject: [PATCH] Simplify routing to fix breakage in popup --- .../network-form/network-form.component.js | 9 +++++---- .../settings/networks-tab/networks-tab.component.js | 4 +++- ui/app/pages/settings/settings.component.js | 12 ++---------- ui/app/pages/settings/settings.container.js | 7 +------ 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js index 249dc8b89..41131138c 100644 --- a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js +++ b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js @@ -68,10 +68,6 @@ export default class NetworkForm extends PureComponent { } componentWillUnmount () { - // onClear will push the network settings route unless was pass false. - // Since we call onClear to cause this component to be unmounted, the - // route will already have been updated, and we avoid setting it twice. - this.props.onClear(false) this.setState({ rpcUrl: '', chainId: '', @@ -80,6 +76,11 @@ export default class NetworkForm extends PureComponent { blockExplorerUrl: '', errors: {}, }) + + // onClear will push the network settings route unless was pass false. + // Since we call onClear to cause this component to be unmounted, the + // route will already have been updated, and we avoid setting it twice. + this.props.onClear(false) } resetForm () { diff --git a/ui/app/pages/settings/networks-tab/networks-tab.component.js b/ui/app/pages/settings/networks-tab/networks-tab.component.js index 36266fdc1..f5a748dab 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.component.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.component.js @@ -101,7 +101,9 @@ export default class NetworksTab extends PureComponent { onClick={() => { setNetworksTabAddMode(false) setSelectedSettingsRpcUrl(rpcUrl) - !isFullScreen && history.push(NETWORKS_FORM_ROUTE) + if (!isFullScreen) { + history.push(NETWORKS_FORM_ROUTE) + } }} >
- - {isFullScreen ? : NetworksTab} - { const isNetworksFormPage = Boolean(pathname.match(NETWORKS_FORM_ROUTE)) const isPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP - const isFullScreen = getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN const pathnameI18nKey = ROUTES_TO_I18N_KEYS[pathname] let backRoute = SETTINGS_ROUTE @@ -90,7 +86,6 @@ const mapStateToProps = (state, ownProps) => { backRoute, currentPath: pathname, isPopup, - isFullScreen, pathnameI18nKey, addressName, initialBreadCrumbRoute,