fix(list): warn when pagination is not a selectable page size - #185
Merged
Conversation
`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.
Contributor
Author
|
🎉 This PR is included in version 2.3.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
paginationis 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:For reference, the browser-side symptom that motivated it, measured on the rendered table before the value was corrected:
Checks
pagination: 10, and none whenpaginateis unset — no false positives.pnpm test(exampleSite build) passes: 40 pages, no errors.LogWarn+warnidconvention in this file, so it is suppressible like the others.Scope
The permitted set
[5, 10, 20, 50]mirrors whatmod-simple-datatablesconfigures insimple-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.