From a91fbae424b3ca1a17a97186f3f920adb1c1ae80 Mon Sep 17 00:00:00 2001 From: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> Date: Thu, 22 Oct 2020 07:27:36 -0400 Subject: [PATCH] [SECURITY_SOLUTION] Fix URL params being carried across to URL routes for which they do not apply (#80726) * Fix URL params issue on Admin section * Fix route location state being dropped during updates to other route properties --- .../public/common/components/url_state/helpers.ts | 1 + .../public/common/utils/route/spy_routes.tsx | 2 ++ .../management/pages/trusted_apps/view/trusted_apps_page.tsx | 4 +--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts b/x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts index 05000f91f094..2be9d27b3fec 100644 --- a/x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts +++ b/x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts @@ -278,6 +278,7 @@ export const replaceStateInLocation = ({ replaceStateKeyInQueryString(urlStateKey, urlStateToReplace)(getQueryStringFromLocation(search)) ); if (history) { + newLocation.state = history.location.state; history.replace(newLocation); } return newLocation.search; diff --git a/x-pack/plugins/security_solution/public/common/utils/route/spy_routes.tsx b/x-pack/plugins/security_solution/public/common/utils/route/spy_routes.tsx index 589436b945a6..febcf0aee679 100644 --- a/x-pack/plugins/security_solution/public/common/utils/route/spy_routes.tsx +++ b/x-pack/plugins/security_solution/public/common/utils/route/spy_routes.tsx @@ -11,6 +11,7 @@ import deepEqual from 'fast-deep-equal'; import { SpyRouteProps } from './types'; import { useRouteSpy } from './use_route_spy'; +import { SecurityPageName } from '../../../../common/constants'; export const SpyRouteComponent = memo< SpyRouteProps & { location: H.Location; pageName: string | undefined } @@ -50,6 +51,7 @@ export const SpyRouteComponent = memo< pathName: pathname, state, tabName, + ...(pageName === SecurityPageName.administration ? { search: search ?? '' } : {}), }, }); setIsInitializing(false); diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx index 822c57b92b4e..2d0b9f759f15 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx @@ -45,9 +45,7 @@ export const TrustedAppsPage = memo(() => { return ; } return null; - // FIXME: Route state is being deleted by some parent component - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [routeState]); const addButton = (