Skip to content

Commit 3aefde1

Browse files
revert: re-integrate signalFilterChange into useUrlFilters (#10028) (#10032)
1 parent 02f3e77 commit 3aefde1

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

ui/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ All notable changes to the **Prowler UI** are documented in this file.
1919
- Filter navigations not coordinating with Suspense boundaries due to missing startTransition in ProviderTypeSelector, AccountsSelector, and muted findings checkbox [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013)
2020
- Scans page pagination not updating table data because ScansTableWithPolling kept stale state from initial mount [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013)
2121
- Duplicate `filter[search]` parameter in findings and scans API calls [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013)
22-
- All filters on `/findings` silently reverting on first click in production [(#10028)](https://github.com/prowler-cloud/prowler/pull/10028)
22+
- All filters on `/findings` silently reverting on first click in production [(#10025)](https://github.com/prowler-cloud/prowler/pull/10025)
2323

2424
---
2525

ui/contexts/filter-transition-context.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ interface FilterTransitionProviderProps {
4343
/**
4444
* Provides a shared pending state for filter changes.
4545
*
46-
* Filter navigation calls signalFilterChange() before router.push().
47-
* The pending state auto-resets when searchParams change.
46+
* Filter components signal the start of navigation via signalFilterChange(),
47+
* and use their own local useTransition() for the actual router.push().
48+
* This avoids a known Next.js production bug where a shared useTransition()
49+
* wrapping router.push() causes the navigation to be silently reverted.
50+
*
51+
* The pending state auto-resets when searchParams change (navigation completed).
4852
*/
4953
export const FilterTransitionProvider = ({
5054
children,

ui/hooks/use-url-filters.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import { usePathname, useRouter, useSearchParams } from "next/navigation";
44

5-
import { useFilterTransitionOptional } from "@/contexts";
6-
75
/**
86
* Custom hook to handle URL filters and automatically reset
97
* pagination when filters change.
@@ -15,14 +13,11 @@ export const useUrlFilters = () => {
1513
const router = useRouter();
1614
const searchParams = useSearchParams();
1715
const pathname = usePathname();
18-
const filterTransition = useFilterTransitionOptional();
16+
const isPending = false;
1917

2018
const navigate = (params: URLSearchParams) => {
2119
const queryString = params.toString();
22-
if (queryString === searchParams.toString()) return;
23-
2420
const targetUrl = queryString ? `${pathname}?${queryString}` : pathname;
25-
filterTransition?.signalFilterChange();
2621
router.push(targetUrl, { scroll: false });
2722
};
2823

@@ -43,9 +38,10 @@ export const useUrlFilters = () => {
4338
// If effective value is unchanged, do nothing (avoids redundant fetches)
4439
if (currentValue === nextValue) return;
4540

46-
// Always reset to first page when filters change.
47-
// This also guarantees a query-string change on page 1 (no existing page param).
48-
params.set("page", "1");
41+
// Only reset page to 1 if page parameter already exists
42+
if (params.has("page")) {
43+
params.set("page", "1");
44+
}
4945

5046
if (nextValue === null) {
5147
params.delete(filterKey);
@@ -62,8 +58,10 @@ export const useUrlFilters = () => {
6258

6359
params.delete(filterKey);
6460

65-
// Always reset to first page when filters change.
66-
params.set("page", "1");
61+
// Only reset page to 1 if page parameter already exists
62+
if (params.has("page")) {
63+
params.set("page", "1");
64+
}
6765

6866
navigate(params);
6967
};
@@ -98,8 +96,10 @@ export const useUrlFilters = () => {
9896
const params = new URLSearchParams(searchParams.toString());
9997
modifier(params);
10098

101-
// Always reset to first page when filters change.
102-
params.set("page", "1");
99+
// Only reset page to 1 if page parameter already exists
100+
if (params.has("page")) {
101+
params.set("page", "1");
102+
}
103103

104104
navigate(params);
105105
};
@@ -109,6 +109,7 @@ export const useUrlFilters = () => {
109109
clearFilter,
110110
clearAllFilters,
111111
hasFilters,
112+
isPending,
112113
navigateWithParams,
113114
};
114115
};

0 commit comments

Comments
 (0)