From 2f10e5308288f4fe47599be5f74a678a9d313d8a Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Wed, 31 Aug 2022 08:31:21 -0700 Subject: [PATCH] Fleet UI: Fix clearing filters on manage host page (#7466) --- changes/issue-7463-fix-clearing-host-filters | 1 + .../hosts/ManageHostsPage/ManageHostsPage.tsx | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 changes/issue-7463-fix-clearing-host-filters diff --git a/changes/issue-7463-fix-clearing-host-filters b/changes/issue-7463-fix-clearing-host-filters new file mode 100644 index 0000000000..d98d472cd1 --- /dev/null +++ b/changes/issue-7463-fix-clearing-host-filters @@ -0,0 +1 @@ +* Clearing filter pill on host detail page only clears that single filter \ No newline at end of file diff --git a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx index 64377c2fd1..de90f3334c 100644 --- a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx +++ b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx @@ -681,18 +681,42 @@ const ManageHostsPage = ({ const handleClearSoftwareFilter = () => { handleResetPageIndex(); - router.replace(PATHS.MANAGE_HOSTS); + router.replace( + getNextLocationPath({ + pathPrefix: PATHS.MANAGE_HOSTS, + routeTemplate, + routeParams, + queryParams: omit(queryParams, ["software_id"]), + }) + ); setSoftwareDetails(null); }; const handleClearMDMSolutionFilter = () => { handleResetPageIndex(); - router.replace(PATHS.MANAGE_HOSTS); + + router.replace( + getNextLocationPath({ + pathPrefix: PATHS.MANAGE_HOSTS, + routeTemplate, + routeParams, + queryParams: omit(queryParams, ["mdm_id"]), + }) + ); setMDMSolutionDetails(null); }; const handleClearMDMEnrollmentFilter = () => { - router.replace(PATHS.MANAGE_HOSTS); + handleResetPageIndex(); + + router.replace( + getNextLocationPath({ + pathPrefix: PATHS.MANAGE_HOSTS, + routeTemplate, + routeParams, + queryParams: omit(queryParams, ["mdm_enrollment_status"]), + }) + ); }; const handleTeamSelect = (teamId: number) => {