Skip to content

[WC-3548]: honor Position of pagination for custom pagination - #2420

Open
yordan-st wants to merge 5 commits into
mainfrom
fix/WC-3548_pagination-position-ignored
Open

yordan-st wants to merge 5 commits into
mainfrom
fix/WC-3548_pagination-position-ignored

Conversation

@yordan-st

@yordan-st yordan-st commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Pull request type

Bug fix (non-breaking change which fixes an issue)

Description

Data Grid 2's "Position of pagination" property already controlled the built-in Pagination control but had no effect on custom pagination: WidgetFooter rendered the custom pagination widgets unconditionally and WidgetTopBar never rendered them at all, so "Above grid" silently did nothing. This mirrors the bug fixed for Gallery, which explicitly scoped Data Grid 2 out to keep that PR reviewable — this is that follow-up.

Custom pagination now honors pagingPosition in both runtime and editor preview: top bar for "Above grid", footer for "Below grid", and footer-only (not duplicated) for "Both" — duplicating the widgets placeholder would duplicate widget instances, DOM ids, and state. pagingPosition stays visible in Studio Pro when custom pagination is enabled (previously hidden as a stopgap), and a new design-time warning explains the single-render behavior for "Both".

What should be covered while testing?

  • Add a Data Grid 2, enable Custom pagination, place a widget in the drop zone.
  • Set "Position of pagination" to "Above grid" → widgets render above the grid, both at runtime and in the Studio Pro page editor preview.
  • Set it to "Below grid" → widgets render below the grid (unchanged from before).
  • Set it to "Both" → widgets render once, below the grid, and Studio Pro shows a warning on the "Position of pagination" property.
  • Confirm "Position of pagination" stays visible/editable in the properties panel while Custom pagination is enabled.
  • Regression: built-in pagination (Custom pagination off) still respects top/bottom/both as before.

No XML changes, no docs PR needed. Changelog entry included in this branch.

Ticket: WC-3548

@yordan-st
yordan-st force-pushed the fix/WC-3548_pagination-position-ignored branch from ea30478 to 7500300 Compare September 10, 2026 13:25
@yordan-st
yordan-st marked this pull request as ready for review September 11, 2026 11:47
@yordan-st
yordan-st requested a review from a team as a code owner September 11, 2026 11:47
@yordan-st
yordan-st force-pushed the fix/WC-3548_pagination-position-ignored branch from 7500300 to 06bb105 Compare September 15, 2026 08:38
@github-actions

This comment has been minimized.

Scopes WC-3548 (custom pagination ignoring Position of pagination),
the Data Grid 2 half of the bug WC-3505 fixed for Gallery.
WidgetFooter rendered custom pagination widgets unconditionally and
WidgetTopBar never rendered them at all. Both now gate on pagingPosition,
mirroring the built-in Pagination control; "both" renders once, in the
footer, to avoid duplicating widget instances/DOM ids/state.
Preview always rendered custom pagination in the footer. Split the
single useCustomPagination() check into top/bottom variants so the
page editor agrees with runtime for every Position of pagination value.
…ination

pagingPosition was hidden from the properties panel whenever custom
pagination was enabled, a stopgap from when the property had no effect.
Now that it does, keep it visible and warn when it's set to "Both" with
custom pagination, since that combination renders once, below the grid.
@yordan-st
yordan-st force-pushed the fix/WC-3548_pagination-position-ignored branch from 06bb105 to c0c76b3 Compare September 15, 2026 13:47
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
src/components/WidgetFooter.tsx Gate custom pagination rendering on pagingPosition !== "top"
src/components/WidgetTopBar.tsx Add custom pagination branch for pagingPosition === "top"
src/Datagrid.editorConfig.ts Stop hiding pagingPosition when custom pagination is enabled
src/Datagrid.editorPreview.tsx Mirror top/bottom placement rule for the preview's CustomPagination
src/consistency-check.ts Add checkCustomPaginationPosition warning for both + custom pagination
src/__tests__/consistency-check.spec.ts New tests for the both-warning and non-warning cases
src/__tests__/__snapshots__/consistency-check.spec.ts.snap New snapshot for the warning
src/components/__tests__/WidgetFooter.spec.tsx New tests: bottom/both renders, top suppresses
src/components/__tests__/WidgetTopBar.spec.tsx New tests: top renders, bottom/both suppressed
CHANGELOG.md User-facing entry for the fix
openspec/changes/pagination-position-not-honored/** OpenSpec artifacts (design, proposal, spec, tasks)

Skipped (out of scope): dist/, pnpm-lock.yaml


Findings

⚠️ Low — Snapshot used for warning message — prefer toEqual assertion

File: src/__tests__/consistency-check.spec.ts line 304
Note: The "warns when custom pagination is enabled and position is both" test uses toMatchSnapshot() on a plain object array containing only static, deterministic values (no dates, IDs, or async data). Snapshots add a maintenance surface: a reviewer seeing the snap file has to cross-reference to understand the expected value, and an accidental wording change silently updates the baseline with -u. The warning message and severity are exactly the kind of thing worth asserting explicitly so a regression is caught rather than silently committed.

Suggested fix:

expect(check(props as unknown as DatagridPreviewProps)).toEqual([
    {
        property: "pagingPosition",
        severity: "warning",
        message:
            'Custom pagination cannot be shown in both positions and will render below the grid. ' +
            'Set "Position of pagination" to "Above grid" or "Below grid" to choose a single position.'
    }
]);

⚠️ Low — Missing test: custom pagination disabled entirely (built-in pagination, all positions)

File: src/components/__tests__/WidgetFooter.spec.tsx, WidgetTopBar.spec.tsx
Note: The new test files only set useCustomPagination: true. They don't assert that the existing built-in pagination still behaves correctly (i.e. that useCustomPagination: false with each pagingPosition value doesn't accidentally render the custom pagination placeholder). This is a regression-guard gap — the condition changed from a simple customPaginationEnabled to customPaginationEnabled && pagingPosition !== "top", so an off-by-one logic error there would go undetected by the current suite. A single extra it block per file covering useCustomPagination: false with "top" would close this.


Positives

  • The pagingPosition condition mirroring Gallery's exact shape (!== "top" for footer, === "top" for top bar) makes cross-widget auditability trivial — a future reader can grep the Gallery fix and immediately verify parity.
  • Removing pagingPosition from hidePropertiesIn by switching to a single hidePropertyIn("showPagingButtons") is clean: no implicit list maintenance, no risk of accidentally re-hiding pagingPosition in a future diff.
  • checkCustomPaginationPosition returning Problem | undefined and being pushed conditionally is consistent with the existing checker style in consistency-check.ts.
  • All three pagingPosition values ("top", "bottom", "both") are covered by both the runtime and editor-preview hooks, and the test files exercise all three paths — good edge-case discipline.
  • The OpenSpec artifacts are thorough and self-contained; the design doc's explicit non-goals (no resolveSlots, no changes to widget-plugin-grid) correctly scope the fix and explain why Gallery's additional machinery isn't needed here.

@iobuhov iobuhov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

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.

3 participants