From 5793dd0193c429c1d8790c1b1b7097e4557c7581 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 4 May 2023 15:52:57 -0500 Subject: [PATCH] UX: Multichain: Focus on test networks when setting is flipped on (#18996) --- .../network-list-menu/network-list-menu.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/components/multichain/network-list-menu/network-list-menu.js b/ui/components/multichain/network-list-menu/network-list-menu.js index 85ca53ea1..bcde1fcc9 100644 --- a/ui/components/multichain/network-list-menu/network-list-menu.js +++ b/ui/components/multichain/network-list-menu/network-list-menu.js @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import React, { useContext, useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; @@ -48,10 +48,21 @@ export const NetworkListMenu = ({ onClose }) => { const environmentType = getEnvironmentType(); const isFullScreen = environmentType === ENVIRONMENT_TYPE_FULLSCREEN; + const showTestNetworksRef = useRef(showTestNetworks); + const networkListRef = useRef(null); + + useEffect(() => { + if (showTestNetworks && !showTestNetworksRef.current) { + // Scroll to the bottom of the list + networkListRef.current.lastChild.scrollIntoView(); + } + showTestNetworksRef.current = showTestNetworks; + }, [showTestNetworks, showTestNetworksRef]); + return ( <> - + {networks.map((network) => { const isCurrentNetwork = currentChainId === network.chainId; const canDeleteNetwork =