Skip to content

fix(admin): ensure content list pagination works correctly#380

Open
kombuchapunk wants to merge 3 commits intoemdash-cms:mainfrom
kombuchapunk:fix/admin-content-list-load-more
Open

fix(admin): ensure content list pagination works correctly#380
kombuchapunk wants to merge 3 commits intoemdash-cms:mainfrom
kombuchapunk:fix/admin-content-list-load-more

Conversation

@kombuchapunk
Copy link
Copy Markdown

Summary

The "Load More" button in the admin content list never appeared — even when collections had more items than a single page. Two bugs in packages/admin/src/:

  1. getNextPageParam returned an empty string instead of undefined (router.tsx) — React Query treats any truthy return as "there's another page", but an empty-string cursor also prevented it from correctly setting hasNextPage = false. Now explicitly returns undefined when there is no next cursor.

  2. limit was conditionally omitted from API requests (lib/api/content.ts) — when no limit was passed, the query param was skipped entirely, causing inconsistent server responses. Now always sends limit (defaults to 100, capped server-side at 100).

Additionally, the explicit limit: 100 in the query call was removed because D1 throws SQL variable limit errors when hydrating SEO data for 100 items. The server default of 50 works correctly with cursor-based pagination.

Test plan

  1. Start a dev server with a seeded collection that has >50 items (e.g. posts)
  2. Open the content list: http://localhost:4321/_emdash/admin/content/posts
  3. Verify:
    • "Load More" button appears below the list
    • Clicking "Load More" appends the next batch of items
    • After all items are loaded, the "Load More" button disappears
    • Client-side page navigation (arrow buttons, "1 / N") still works within each loaded batch
    • Collections with <50 items do not show a "Load More" button

This fixes an issue where the "Load More" button would not appear in the
admin content list, even when there were more items to load.

Changes:
- Always include the `limit` parameter in content list API requests,
  defaulting to 100 for better UX in admin lists
- Make `getNextPageParam` more robust by explicitly validating that
  `nextCursor` is a non-empty string before returning it
100 items causes D1 SQL variable limit errors when hydrating SEO data.
Server default of 50 works correctly with pagination.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

⚠️ No Changeset found

Latest commit: 413915e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant