mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ All notable changes to the **Prowler UI** are documented in this file.
|
|||||||
- 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)
|
- 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)
|
||||||
- Scans page pagination not updating table data because ScansTableWithPolling kept stale state from initial mount [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013)
|
- Scans page pagination not updating table data because ScansTableWithPolling kept stale state from initial mount [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013)
|
||||||
- Duplicate `filter[search]` parameter in findings and scans API calls [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013)
|
- Duplicate `filter[search]` parameter in findings and scans API calls [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013)
|
||||||
- All filters on `/findings` silently reverting on first click in production [(#10028)](https://github.com/prowler-cloud/prowler/pull/10028)
|
- All filters on `/findings` silently reverting on first click in production [(#10025)](https://github.com/prowler-cloud/prowler/pull/10025)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,12 @@ interface FilterTransitionProviderProps {
|
|||||||
/**
|
/**
|
||||||
* Provides a shared pending state for filter changes.
|
* Provides a shared pending state for filter changes.
|
||||||
*
|
*
|
||||||
* Filter navigation calls signalFilterChange() before router.push().
|
* Filter components signal the start of navigation via signalFilterChange(),
|
||||||
* The pending state auto-resets when searchParams change.
|
* and use their own local useTransition() for the actual router.push().
|
||||||
|
* This avoids a known Next.js production bug where a shared useTransition()
|
||||||
|
* wrapping router.push() causes the navigation to be silently reverted.
|
||||||
|
*
|
||||||
|
* The pending state auto-resets when searchParams change (navigation completed).
|
||||||
*/
|
*/
|
||||||
export const FilterTransitionProvider = ({
|
export const FilterTransitionProvider = ({
|
||||||
children,
|
children,
|
||||||
|
|||||||
+14
-13
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||||
|
|
||||||
import { useFilterTransitionOptional } from "@/contexts";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom hook to handle URL filters and automatically reset
|
* Custom hook to handle URL filters and automatically reset
|
||||||
* pagination when filters change.
|
* pagination when filters change.
|
||||||
@@ -15,14 +13,11 @@ export const useUrlFilters = () => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const filterTransition = useFilterTransitionOptional();
|
const isPending = false;
|
||||||
|
|
||||||
const navigate = (params: URLSearchParams) => {
|
const navigate = (params: URLSearchParams) => {
|
||||||
const queryString = params.toString();
|
const queryString = params.toString();
|
||||||
if (queryString === searchParams.toString()) return;
|
|
||||||
|
|
||||||
const targetUrl = queryString ? `${pathname}?${queryString}` : pathname;
|
const targetUrl = queryString ? `${pathname}?${queryString}` : pathname;
|
||||||
filterTransition?.signalFilterChange();
|
|
||||||
router.push(targetUrl, { scroll: false });
|
router.push(targetUrl, { scroll: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,9 +38,10 @@ export const useUrlFilters = () => {
|
|||||||
// If effective value is unchanged, do nothing (avoids redundant fetches)
|
// If effective value is unchanged, do nothing (avoids redundant fetches)
|
||||||
if (currentValue === nextValue) return;
|
if (currentValue === nextValue) return;
|
||||||
|
|
||||||
// Always reset to first page when filters change.
|
// Only reset page to 1 if page parameter already exists
|
||||||
// This also guarantees a query-string change on page 1 (no existing page param).
|
if (params.has("page")) {
|
||||||
params.set("page", "1");
|
params.set("page", "1");
|
||||||
|
}
|
||||||
|
|
||||||
if (nextValue === null) {
|
if (nextValue === null) {
|
||||||
params.delete(filterKey);
|
params.delete(filterKey);
|
||||||
@@ -62,8 +58,10 @@ export const useUrlFilters = () => {
|
|||||||
|
|
||||||
params.delete(filterKey);
|
params.delete(filterKey);
|
||||||
|
|
||||||
// Always reset to first page when filters change.
|
// Only reset page to 1 if page parameter already exists
|
||||||
params.set("page", "1");
|
if (params.has("page")) {
|
||||||
|
params.set("page", "1");
|
||||||
|
}
|
||||||
|
|
||||||
navigate(params);
|
navigate(params);
|
||||||
};
|
};
|
||||||
@@ -98,8 +96,10 @@ export const useUrlFilters = () => {
|
|||||||
const params = new URLSearchParams(searchParams.toString());
|
const params = new URLSearchParams(searchParams.toString());
|
||||||
modifier(params);
|
modifier(params);
|
||||||
|
|
||||||
// Always reset to first page when filters change.
|
// Only reset page to 1 if page parameter already exists
|
||||||
params.set("page", "1");
|
if (params.has("page")) {
|
||||||
|
params.set("page", "1");
|
||||||
|
}
|
||||||
|
|
||||||
navigate(params);
|
navigate(params);
|
||||||
};
|
};
|
||||||
@@ -109,6 +109,7 @@ export const useUrlFilters = () => {
|
|||||||
clearFilter,
|
clearFilter,
|
||||||
clearAllFilters,
|
clearAllFilters,
|
||||||
hasFilters,
|
hasFilters,
|
||||||
|
isPending,
|
||||||
navigateWithParams,
|
navigateWithParams,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user