Skip to content

sortDirection default in config changes hooks is a dead param — sort defaults never reach useReactTableSortState #2855

@adityathebe

Description

@adityathebe

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:

  1. Wrong key name: useReactTableSortState reads sortOrder, not sortDirection. Nothing in the codebase ever calls params.get("sortDirection"). This has been wrong since the code was written (exists on main).

  2. Defaults don't propagate across hook instances: Even if the key were fixed to sortOrder, the defaults passed to this usePrefixedSearchParams call are only visible to its own returned searchParams object (React Router's useSearchParams scopes defaultInit per hook instance via useRef). The actual sort values sent to the API come from useReactTableSortState({ paramPrefix }), which is a separate usePrefixedSearchParams instance with no defaults — so it sees no sort params and returns [], making sortBy: 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions