From 6dbc1f1b6ad4c5e4968ac987cbbc4c3f45c30564 Mon Sep 17 00:00:00 2001 From: Emre Bogazliyanlioglu Date: Fri, 20 Sep 2024 22:19:46 +0300 Subject: [PATCH] [Redesign] Automatic route selection should overwrite invalid routes (#2687) Signed-off-by: Emre Bogazliyanlioglu --- wormhole-connect/src/views/v2/Bridge/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wormhole-connect/src/views/v2/Bridge/index.tsx b/wormhole-connect/src/views/v2/Bridge/index.tsx index 6bd897105..381dea856 100644 --- a/wormhole-connect/src/views/v2/Bridge/index.tsx +++ b/wormhole-connect/src/views/v2/Bridge/index.tsx @@ -165,9 +165,14 @@ const Bridge = () => { setSelectedRoute(''); } else { const autoselectedRoute = route || validRoutes[0].route.name; + const isSelectedRouteValid = + validRoutes.findIndex((r) => r.route.name === selectedRoute) > -1; - // avoids overwriting selected route - if (!autoselectedRoute || !!selectedRoute) return; + // If no route is autoselected or we already have a valid selected route, + // we should avoid to overwrite it + if (!autoselectedRoute || (selectedRoute && isSelectedRouteValid)) { + return; + } const routeData = validRoutes?.find( (rs) => rs.route.name === autoselectedRoute,