Skip to content

Fix paginationConfigs type in useCioPlp to match CioPlpGrid#240

Open
esezen wants to merge 7 commits intomainfrom
nocdx-fix-pagination-configs-type
Open

Fix paginationConfigs type in useCioPlp to match CioPlpGrid#240
esezen wants to merge 7 commits intomainfrom
nocdx-fix-pagination-configs-type

Conversation

@esezen
Copy link
Copy Markdown
Contributor

@esezen esezen commented Apr 21, 2026

Pull Request Checklist

Before you submit a pull request, please make sure you have to following:

  • I have added or updated TypeScript types for my changes, ensuring they are compatible with the existing codebase.
  • I have added JSDoc comments to my TypeScript definitions for improved documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added any necessary documentation (if appropriate).
  • I have made sure my PR is up-to-date with the main branch.

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no API changes)
  • Documentation content changes
  • TypeScript type definitions update
  • Other... Please describe:

What's up

Tiny follow-up to #230 (CDX-425). That PR added useAnchors on PaginationProps and updated CioPlpGridProps.paginationConfigs to use Omit<PaginationProps, 'totalNumResults'> — but the twin declaration on UseCioPlpProps got left on the old UsePaginationProps type. So if you use the headless useCioPlp hook directly and try to pass paginationConfigs={{ useAnchors: true }}, TS yells at you even though <Pagination> happily accepts it.

This bumps useCioPlp's paginationConfigs to the same type so the two public surfaces match. Also copied over the JSDoc bit about useAnchors / the v2 deprecation note from CioPlpGrid so IntelliSense stays consistent.

Notes

  • Type-only change, no runtime impact. PaginationProps is a strict superset of UsePaginationProps (just adds optional useAnchors), so nothing breaks for existing consumers.
  • No new tests since there's no new behavior — the useAnchors runtime path is already covered by the Pagination specs added in [CDX-425] Add seo friendly anchor based pagination #230.

CDX-425 (#230) retyped CioPlpGridProps.paginationConfigs from
Omit<UsePaginationProps, 'totalNumResults'> to
Omit<PaginationProps, 'totalNumResults'> so consumers could pass
useAnchors, but the parallel declaration on UseCioPlpProps was missed.
Headless consumers of useCioPlp couldn't pass useAnchors without a TS
error. Retype to restore parity.
Copilot AI review requested due to automatic review settings April 21, 2026 20:22
@esezen esezen requested a review from a team as a code owner April 21, 2026 20:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the public paginationConfigs type exposed by the headless useCioPlp hook with the CioPlpGrid component, so consumers can pass useAnchors (added in #230) without TypeScript errors.

Changes:

  • Update UseCioPlpProps.paginationConfigs to Omit<PaginationProps, 'totalNumResults'> to match CioPlpGrid.
  • Add JSDoc documentation for useAnchors / v2 deprecation note to keep IntelliSense consistent.
  • Remove the now-unused UsePaginationProps import from useCioPlp.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

constructor-claude-bedrock[bot]

This comment was marked as outdated.

Mudaafi
Mudaafi previously approved these changes Apr 21, 2026
Copy link
Copy Markdown
Contributor

@Mudaafi Mudaafi left a comment

Choose a reason for hiding this comment

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

good catch!

constructor-claude-bedrock[bot]

This comment was marked as outdated.

Mudaafi
Mudaafi previously approved these changes Apr 21, 2026
constructor-claude-bedrock[bot]

This comment was marked as outdated.

Mudaafi
Mudaafi previously approved these changes Apr 23, 2026
Copy link
Copy Markdown
Contributor

@Mudaafi Mudaafi left a comment

Choose a reason for hiding this comment

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

lgtm just some code placements

Comment thread spec/components/CioPlpGrid/CioPlpGrid.test.jsx Outdated
Comment on lines +431 to +433
expect(mockPagination.mock.calls[0][0]).toEqual(
expect.objectContaining({ useAnchors: true, windowSize: 7 }),
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Aye aye captain 7caa1df

constructor-claude-bedrock[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@constructor-claude-bedrock constructor-claude-bedrock Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR fixes a type mismatch between UseCioPlpProps.paginationConfigs and CioPlpGridProps.paginationConfigs by upgrading the former to use Omit<PaginationProps, 'totalNumResults'>, and adds integration tests verifying paginationConfigs forwarding.

Inline comments: 3 discussions added

Overall Assessment: ⚠️ Needs Work


await waitFor(() => {
expect(mockPagination).toHaveBeenCalled();
expect(mockPagination.mock.calls[0][0]).toEqual(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: mockPagination.mock.calls[0][0] is fragile — it asserts against the first call, but the Pagination component may render multiple times (e.g. initial render before data loads, then after). If a render cycle changes, this index silently tests the wrong invocation. Prefer mockPagination.mock.lastCall[0] or collect all calls and assert the last one:

const lastCallProps = mockPagination.mock.calls[mockPagination.mock.calls.length - 1][0];
expect(lastCallProps).toEqual(expect.objectContaining({ useAnchors: true, windowSize: 7 }));

This applies to both the CioPlpGrid-level and CioPlp-level tests.

});
});

it('Should forward paginationConfigs to the Pagination component when passed at CioPlp level', async () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important Issue: This test passes paginationConfigs at the <CioPlp> level and asserts that the <Pagination> component receives those props. However, <CioPlp> forwards paginationConfigs to <CioPlpGrid>, which then spreads it directly onto <Pagination> — it does not flow through useCioPlp. This test therefore does not validate the scenario described in the PR description (a user calling useCioPlp({ paginationConfigs: { useAnchors: true } }) directly from the headless hook). A dedicated test for the headless hook path (e.g. a useCioPlp.test or a CioPlp test that renders custom children using the hook) would be needed to prove the type fix has the intended runtime effect.

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.

3 participants