Skip to content

Fixed sortingFilter param in gdpr extractor#3333

Open
Corepex wants to merge 2 commits into2025.4from
2885-gdpr-sorting-only-works-on-the-first-page
Open

Fixed sortingFilter param in gdpr extractor#3333
Corepex wants to merge 2 commits into2025.4from
2885-gdpr-sorting-only-works-on-the-first-page

Conversation

@Corepex
Copy link
Copy Markdown
Contributor

@Corepex Corepex commented Apr 13, 2026

Changes in this pull request

Resolves #2885

Additional info

This pull request refines the sorting and pagination logic in the GDPRDataExtractorContainer component to improve user experience and state management. The main focus is on ensuring that changing the sort order resets the page to 1 and that the sort state is properly tracked and updated.

Improvements to sorting and pagination logic:

  • Added a new sortFilter state using useState to track the current sort order.
  • Updated the executeSearch function to:
    • Set the sortFilter state when a new sort is applied.
    • Reset the page to 1 when the sort filter changes and no explicit page override is provided, ensuring users always start at the first page after sorting.
    • Keep the current page unless a sort change occurs, in which case the page is reset.

@Corepex Corepex self-assigned this Apr 13, 2026
@Corepex Corepex linked an issue Apr 13, 2026 that may be closed by this pull request
@Corepex Corepex requested a review from xIrusux April 13, 2026 08:47
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@xIrusux xIrusux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The page reset on sort change makes sense and should fix the “sorting only works on the first page” behavior. I’d just suggest deriving nextSortFilter / nextPage first and using those for the request, then updating state afterward. That makes the flow easier to read and avoids mixing request and state updates.

I.e.

const nextSortFilter = overrides?.sortFilter ?? sortFilter
const isSortChange = overrides?.sortFilter !== undefined && overrides?.page === undefined
const nextPage = isSortChange ? 1 : (overrides?.page ?? page)
const nextProvider = overrides?.provider ?? provider
const nextColumnFilters = overrides?.columnFilters ?? columnFilters
const nextPageSize = overrides?.pageSize ?? pageSize

if (overrides?.sortFilter !== undefined) {
  setSortFilter(overrides.sortFilter)
}
if (isSortChange) {
  setPage(1)
}

if (nextProvider === '' || isEmpty(nextColumnFilters)) return

void trigger({

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GDPR] sorting only works on the first page

2 participants