Skip to content

Commit 47b5685

Browse files
committed
refactor filter behaviour
Signed-off-by: Atif Ali <atali@redhat.com>
1 parent cbd3ec6 commit 47b5685

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/gitops/components/shared/ApplicationList.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,17 @@ const ApplicationList: React.FC<ApplicationProps> = ({
109109
return sortData(applications, sortBy, direction);
110110
}, [applications, sortBy, direction]);
111111

112-
// Filter applications by project or appset BEFORE calculating filter counts
113-
const filteredByOwner = React.useMemo(
112+
// Filter applications by project or appset FIRST - before PatternFly filters
113+
// This ensures PF filters work on the correct dataset (owned apps only)
114+
const ownedApps = React.useMemo(
114115
() => sortedApplications.filter(filterApp(project, appset)),
115116
[sortedApplications, project, appset],
116117
);
117118

118119
// TODO: use alternate filter since it is deprecated. See DataTableView potentially
120+
// PatternFly filters work on owned apps only (the dataset that will be displayed)
119121
const filters = getFilters(t);
120-
const [data, filteredData, onFilterChange] = useListPageFilter(filteredByOwner, filters);
122+
const [data, filteredData, onFilterChange] = useListPageFilter(ownedApps, filters);
121123

122124
// Filter by search query if present (after other filters)
123125
const filteredBySearch = React.useMemo(() => {
@@ -134,10 +136,8 @@ const ApplicationList: React.FC<ApplicationProps> = ({
134136
}, [filteredData, searchQuery]);
135137
const rows = useApplicationRowsDV(filteredBySearch, namespace);
136138

137-
// Check if there are applications owned by this ApplicationSet initially (before search)
138-
const hasOwnedApplications = React.useMemo(() => {
139-
return filteredByOwner.length > 0;
140-
}, [filteredByOwner]);
139+
// Check if there are applications owned by this ApplicationSet initially (before filters/search)
140+
const hasOwnedApplications = ownedApps.length > 0;
141141
const empty = (
142142
<Tbody>
143143
<Tr key="loading" ouiaId="table-tr-loading">

0 commit comments

Comments
 (0)