-
Notifications
You must be signed in to change notification settings - Fork 25
Description
In src/api/query-hooks/useConfigChangesHooks.ts, both useGetAllConfigsChangesQuery (line 55-58) and useGetConfigChangesByIDQuery (line 104-108) pass sort defaults to usePrefixedSearchParams:
const [params] = usePrefixedSearchParams(paramPrefix, false, {
sortBy: "created_at",
sortDirection: "desc" // wrong key — nothing reads "sortDirection"
});Two issues:
-
Wrong key name:
useReactTableSortStatereadssortOrder, notsortDirection. Nothing in the codebase ever callsparams.get("sortDirection"). This has been wrong since the code was written (exists onmain). -
Defaults don't propagate across hook instances: Even if the key were fixed to
sortOrder, the defaults passed to thisusePrefixedSearchParamscall are only visible to its own returnedsearchParamsobject (React Router'suseSearchParamsscopesdefaultInitper hook instance viauseRef). The actual sort values sent to the API come fromuseReactTableSortState({ paramPrefix }), which is a separateusePrefixedSearchParamsinstance with no defaults — so it sees no sort params and returns[], makingsortBy: undefined, sortOrder: "asc".
The same pattern exists in src/pages/config/details/ConfigDetailsChangesPage.tsx (line 11-14).
Net effect: the sort defaults on these config changes queries are entirely inert. The API receives sortBy: undefined instead of sortBy: "created_at" on initial load (until the user clicks a column header).