Skip to content

Commit 21c32a8

Browse files
fix(view): address Reviewer A/B consensus findings (round 4)
Forward `windowSize` to `pageNumberLinks()` on the `paginationNav()` viewStyle path so the auto-mode predicate and the rendered window are evaluated against the same value. - `vendor/wheels/view/pagination.cfc`: add `numeric windowSize` to `$renderPaginationNav()` signature, pass `windowSize` at the call site, and copy it into `local.pageArgs` before invoking `pageNumberLinks()`. - `vendor/wheels/tests/specs/view/paginationHelpersSpec.cfc`: add a regression-guard spec under "paginationNav with viewStyle presets" asserting that `paginationNav(viewStyle="bootstrap5", windowSize=4)` with `currentPage=5, totalRecords=100, perPage=10` includes page 8 in the output. Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
1 parent 0c79f86 commit 21c32a8

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

vendor/wheels/tests/specs/view/paginationHelpersSpec.cfc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,18 @@ component extends="wheels.WheelsTest" {
369369
}).toThrow("Wheels.InvalidViewStyle")
370370
})
371371

372+
it("forwards windowSize to pageNumberLinks() on the viewStyle path", () => {
373+
g.setPagination(totalRecords = 100, currentPage = 5, perPage = 10)
374+
result = _controller.paginationNav(viewStyle = "bootstrap5", windowSize = 4)
375+
// windowSize=4 expands the rendered page-number window to pages 1-9,
376+
// so page 8 must appear in the output. If windowSize were silently
377+
// dropped from the $renderPaginationNav() → pageNumberLinks() call
378+
// (default 2), the window would shrink to 3-7 and page 8 would
379+
// disappear — guards against the auto-mode predicate and rendered
380+
// window using mismatched windowSize values.
381+
expect(result).toInclude(">8<")
382+
})
383+
372384
})
373385

374386
/* ── paginationNav ─────────────────────────── */

vendor/wheels/view/pagination.cfc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ component {
511511
showPrevious = $paginationShouldShowAnchor(mode = local.previousMode, side = "previous", pg = local.pg, windowSize = arguments.windowSize),
512512
showNext = $paginationShouldShowAnchor(mode = local.nextMode, side = "next", pg = local.pg, windowSize = arguments.windowSize),
513513
showLast = $paginationShouldShowAnchor(mode = local.lastMode, side = "last", pg = local.pg, windowSize = arguments.windowSize),
514+
windowSize = arguments.windowSize,
514515
subArgs = local.subArgs
515516
);
516517
}
@@ -819,6 +820,7 @@ component {
819820
required boolean showPrevious,
820821
required boolean showNext,
821822
required boolean showLast,
823+
required numeric windowSize,
822824
required struct subArgs
823825
) {
824826
local.firstDisabled = arguments.pg.currentPage <= 1;
@@ -845,8 +847,11 @@ component {
845847
}
846848

847849
// Reuse pageNumberLinks() so the window logic stays in one place.
850+
// windowSize is excluded from subArgs (see skipArgs in paginationNav), so
851+
// re-add it here to keep the auto-mode predicate and rendered window aligned.
848852
local.pageArgs = StructCopy(arguments.subArgs);
849853
local.pageArgs.viewStyle = arguments.viewStyle;
854+
local.pageArgs.windowSize = arguments.windowSize;
850855
local.items &= pageNumberLinks(argumentCollection = local.pageArgs);
851856

852857
if (arguments.showNext) {

0 commit comments

Comments
 (0)