8000 Fix duplicated resource on current and next page in Auth Resources by andreqrochaa · Pull Request #47446 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Fix duplicated resource on current and next page in Auth Resources - #47446

Merged
ahus1 merged 2 commits into
keycloak:mainfrom
andreqrochaa:fix-46088
Apr 17, 2026
Merged

ahus1 merged 2 commits into
keycloak:mainfrom
andreqrochaa:fix-46088

Conversation

@andreqrochaa
Copy link
Copy Markdown
Contributor

Closes: #46088

The data duplication issue in the Authorization Resources table occurred due to the pagination fetch logic. The useFetch hook is designed to request max + 1 items from the API to determine if a "Next" page exists. However, the UI was incorrectly rendering the entire returned array instead of limiting the display to the max value defined for the current page. As a result, the (N+1)-th item (which should only serve as a pagination indicator) was being displayed as the last item of the current page and then again as the first item of the next page.

To fix this issue, I implemented a .slice(0, max) on the resources array in Resources.tsx before mapping the data to the table rows. This ensures that even though N+1 items are fetched for background logic, only N items are rendered to the user, maintaining data uniqueness across paginated views.

For testing, I created 11 resources and verified that no duplication occurs when navigating between Page 1 and Page 2, and added a new Playwright E2E test in authorization.spec.ts that programmatically verifies the correct distribution of 11 resources across two pages.

The Authorization Resources table was incorrectly duplicating the last
element of the current page as the first element of the next page.

This occurred because the fetching logic requests 'max + 1' items to
detect if a subsequent page exists. However, the UI was rendering the
entire array instead of limiting the display to the 'max' value.

Fixed by applying a .slice(0, max) before mapping the resources to
table rows. Added a Playwright E2E regression test to ensure unique
resource distribution across pages and prevent future regressions.

Closes #46088

Signed-off-by: André Rocha <andre.queiroz.rocha@tecnico.ulisboa.pt>
@andreqrochaa
andreqrochaa requested review from a team as code owners March 25, 2026 14:14
@andreqrochaa
Copy link
Copy Markdown
Contributor Author

Hi @edewit and @jonkoops,

I'm following up on this PR as it addresses the duplicated resource bug in the Authorization Resources list. Since you are the main contributors to this file, I was wondering if you could provide some feedback or review the proposed fix.

Please let me know if any further adjustments are needed to get this merged.

Thanks!

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
@ahus1 ahus1 self-assigned this Apr 17, 2026
@ahus1 ahus1 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for this PR, great to see this one fixed!

@ahus1
ahus1 merged commit 95cfffc into keycloak:main Apr 17, 2026
71 of 73 checks passed
@stianst stianst mentioned this pull request Jun 1, 2026
sashyo pushed a commit to tide-foundation/keycloak-IGA that referenced this pull request Jul 20, 2026
…eycloak#47446)

The Authorization Resources table was incorrectly duplicating the last
element of the current page as the first element of the next page.

This occurred because the fetching logic requests 'max + 1' items to
detect if a subsequent page exists. However, the UI was rendering the
entire array instead of limiting the display to the 'max' value.

Fixed by applying a .slice(0, max) before mapping the resources to
table rows. Added a Playwright E2E regression test to ensure unique
resource distribution across pages and prevent future regressions.

Closes keycloak#46088

---------

Signed-off-by: André Rocha <andre.queiroz.rocha@tecnico.ulisboa.pt>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Co-authored-by: Alexander Schwartz <alexander.schwartz@ibm.com>
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.

Newly created resource appears on both current and next page in Authorization Resources tab

2 participants

0