Skip to content

Feature: Allow Manual Override of Pagination canNextPage/canPreviousPage#6385

Draft
rtablada wants to merge 1 commit into
TanStack:betafrom
rtablada:feat-explicit-can-page
Draft

Feature: Allow Manual Override of Pagination canNextPage/canPreviousPage#6385
rtablada wants to merge 1 commit into
TanStack:betafrom
rtablada:feat-explicit-can-page

Conversation

@rtablada

@rtablada rtablada commented Jul 6, 2026

Copy link
Copy Markdown

🎯 Changes

This adds explicit canNextPage and canPreviousPage options to Pagination state.

In large data scale pagination (news feeds, financial, live updates, etc), counts may not be accurate to whether or not pages are available. In these cases it is common for REST (JSON:API) or GraphQL requests to add information on how to navigate to next/previous pages and whether or not those pages exist.

Alternative

For these cases consumers could use a separate store with fallback to Tanstack pagination atom/state. However this means having to manage two state objects and in cases of Frameworks where signal evaluation is lazy (Ember/Vue/Solid), it can be easy to return before all reactive state are evaluated and be in a situation where a value is not properly observed in the case of fallback behavior.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4818e355-9e01-47b2-aae4-62b57e7c7923

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@@ -251,7 +251,14 @@ export function table_getCanPreviousPage<
TFeatures extends TableFeatures,
TData extends RowData,
>(table: Table_Internal<TFeatures, TData>) {
return (table.atoms.pagination?.get()?.pageIndex ?? 0) > 0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Previously this used ?? 0. However this is now updated to use the same defaultPageIndex const as table_getCanNextPage for consistency

Comment on lines +254 to +255
const pagination = table.atoms.pagination?.get()
const { canPreviousPage, pageIndex } = pagination ?? {}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Destructuring before any return condition ensures reactivity for lazy eval frameworks are maintained.

This is important in the case where pageIndex is declared as a lazy getter in frameworks such as Solid/Angular/Ember.

@@ -0,0 +1,123 @@
import { describe, expect, it } from 'vitest'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Net new unit tests.

@rtablada

rtablada commented Jul 6, 2026

Copy link
Copy Markdown
Author

In this, I updated only the React docs. I'm not sure if there is a sync script or existing prompt to sync similar API change docs across all FWs

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.

1 participant