diff --git a/changes/21594-host-software-filter-bug b/changes/21594-host-software-filter-bug new file mode 100644 index 0000000000..fb7ff11dda --- /dev/null +++ b/changes/21594-host-software-filter-bug @@ -0,0 +1 @@ +- Fleet UI: Fix host software filter bug that resets dropdown filter on table changes (pagination, order by column, etc) diff --git a/frontend/pages/hosts/details/cards/Software/HostSoftwareTable/HostSoftwareTable.tsx b/frontend/pages/hosts/details/cards/Software/HostSoftwareTable/HostSoftwareTable.tsx index be7a476d78..99275f7751 100644 --- a/frontend/pages/hosts/details/cards/Software/HostSoftwareTable/HostSoftwareTable.tsx +++ b/frontend/pages/hosts/details/cards/Software/HostSoftwareTable/HostSoftwareTable.tsx @@ -118,6 +118,7 @@ const HostSoftwareTable = ({ /> ); }, [handleFilterDropdownChange, hostSoftwareFilter]); + const determineQueryParamChange = useCallback( (newTableQuery: ITableQueryData) => { const changedEntry = Object.entries(newTableQuery).find(([key, val]) => { @@ -148,9 +149,15 @@ const HostSoftwareTable = ({ page: changedParam === "pageIndex" ? newTableQuery.pageIndex : 0, }; + if (hostSoftwareFilter === "vulnerableSoftware") { + newQueryParam.vulnerable = "true"; + } else if (hostSoftwareFilter === "installableSoftware") { + newQueryParam.available_for_install = "true"; + } + return newQueryParam; }, - [] + [hostSoftwareFilter] ); // TODO: Look into useDebounceCallback with dependencies