Skip to content

fix(list): warn when pagination is not a selectable page size - #185

Merged
markdumay merged 1 commit into
mainfrom
fix/validate-pagination
Jul 30, 2026
Merged

fix(list): warn when pagination is not a selectable page size#185
markdumay merged 1 commit into
mainfrom
fix/validate-pagination

Conversation

@markdumay

Copy link
Copy Markdown
Contributor

The problem

pagination is passed straight through to the datatable without being checked against the per-page options the control will offer. When the two disagree, the control renders its own first option while the table pages at the requested size — so the reader sees "5" above a page of 25 rows.

Nothing surfaces at build time. The only way to notice is to count rows in a browser.

The change

Warn at Hugo time, naming the value, the permitted set, the consequence, and both remedies. Skipped when the author supplies their own option list via pagination-select, since the permitted set is then theirs.

Verified against a real site (infusal.io) with pagination: 25:

WARN  partial [component-library/components/list/list.hugo.html] -
      Invalid pagination: integrations/_index.md
      pagination is 25, which is not one of 5, 10, 20, 50; the per-page
      control will show its first option instead. Pick a permitted
      value or set 'pagination-select'.
You can suppress this warning by adding the following to your project configuration:
ignoreLogs = ['warn-invalid-pagination']

For reference, the browser-side symptom that motivated it, measured on the rendered table before the value was corrected:

data-table-paging-option-perPage = "25"
select.value                     = "5"        <- first option, not 25
visible tbody rows               = 25
select options                   = 5, 10, 20, 50, All

Checks

  • No warning at pagination: 10, and none when paginate is unset — no false positives.
  • pnpm test (exampleSite build) passes: 40 pages, no errors.
  • Follows the existing LogWarn + warnid convention in this file, so it is suppressible like the others.

Scope

The permitted set [5, 10, 20, 50] mirrors what mod-simple-datatables configures in simple-datatables.load.js. This catches the common authoring mistake early; it cannot cover callers that reach that module directly. A companion issue for runtime validation there is worth raising separately — silently rendering a mismatched value is the worst of the available outcomes.

`pagination` was passed straight through to the datatable without being
checked against the per-page options the control will offer. When the two
disagree the control renders its own first option while the table pages
at the requested size, so the reader sees "5" above a 25-row page. Nothing
surfaces at build time — it is visible only in a browser.

Warn instead, naming the value, the permitted set, the consequence and
both remedies. Skipped when the author supplies their own option list via
`pagination-select`, since the permitted set is then theirs.

Verified against a real site (infusal.io) with `pagination: 25`:

  WARN  partial [component-library/components/list/list.hugo.html] -
        Invalid pagination: integrations/_index.md
        pagination is 25, which is not one of 5, 10, 20, 50; the per-page
        control will show its first option instead. Pick a permitted
        value or set 'pagination-select'.

No warning at `pagination: 10`, and no warning when `paginate` is unset.
`pnpm test` (exampleSite build) passes: 40 pages, no errors.
@markdumay
markdumay merged commit 6c207b6 into main Jul 30, 2026
8 checks passed
@markdumay

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 2.3.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant