[spike] Fix card-list rail pagination on short final page - #4971
Draft
Jimmy cook (jimmycook) wants to merge 1 commit into
Draft
[spike] Fix card-list rail pagination on short final page#4971Jimmy cook (jimmycook) wants to merge 1 commit into
Jimmy cook (jimmycook) wants to merge 1 commit into
Conversation
When a row/rail's final page holds fewer cards than initiallyShownCards (odd totals, e.g. 3 cards shown 2-wide), physical scrolling to the end never advanced the pagination indicator: firstVisibleIndex could not reach the last page's start card, so Math.floor(firstVisibleIndex / shown) stayed on the previous page. Fix: in usePageScrollSync, if the last card is visible we've reached the end, so snap the indicator to the final page. Adds two Storybook repro stories (2-wide/3-card and 4-wide/10-card) and a unit test for the short-final-page case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Visit https://backpack.github.io/storybook-prs/4971 to see this build running in a browser. |
Contributor
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.
Spike
Investigating a pagination bug in
BpkCardListrow/rail mode.Problem
When the final page of a rail holds fewer cards than
initiallyShownCards(odd totals — e.g. 3 cards shown 2-wide), physically scrolling to the end does not advance the pagination indicator.Cause: in
usePageScrollSync, the page index is derived fromMath.floor(firstVisibleIndex / initiallyShownCards). On a short final page there isn't enough content to scroll that page's first card to the viewport start, sofirstVisibleIndexnever reaches it and the indicator stays on the previous page.Change
BpkCardListRowRail/utils.tsx— inusePageScrollSync, if the last card is visible we've reached the end, so snap the indicator to the final page (totalPages - 1); otherwise the existing calculation is used.BpkCardListRowRail/utils-test.tsx— unit test for the short-final-page case.BpkCardList.stories.tsx— two repro stories:RowToRailShortFinalPage(2-wide, 3 cards)RowToRailShortFinalPageWider(4-wide, 10 cards)How to review
Storybook →
bpk-component-card-list→ the twoRowToRailShortFinalPage*stories. On desktop, physically scroll to the last card; the indicator now tracks to the final page.pnpm jest packages/backpack-web/src/bpk-component-card-listis green (61 tests).Notes
Draft / spike — no changelog entry yet, wanted a sanity check on the approach before polishing.
🤖 Generated with Claude Code