Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination algorithm enhancements #5504

Merged
merged 23 commits into from
Jan 16, 2025

Conversation

hectahertz
Copy link
Contributor

This PR replaces the Pagination algorithm to optimize how we decide which page numbers to render so the buttons stay in place, so we can reduce friction and make it easier to use for users with dexterity issues.

Changelog

New

Added a couple of tests for the new algorithm.

    ✓ adds a page when there would be only one page hidden by the left ellipsis
    ✓ adds a page when there would be only one page hidden by the right ellipsis

Changed

The algorithm has been completely rewritten, simplified and documented with the goal of increasing legibility and maintainability.

The previous algorithm relied heavily on traversing the list of pages back and forth and sliding counters and ranges. This new version calculates the dimensions of the different parts in one go, with visual explanations of the math in the comments.

The new algorithm has also two UX improvements:

  • Doesn't create ellipsis when there's only a gap of one page, it just renders it.
  • Keeps the number of pages shown in total consistent, making the dimensions of the overall component and the positions of the buttons static.

Previous UX

previous.mov

New UX (same parameters)

new.mov

This PR also changed the styling of the Previous and Next buttons so they always keep the chevron and their dimensions, even when disabled.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Added two tests which should be pretty self explanatory

Merge checklist

@hectahertz hectahertz requested a review from a team as a code owner January 8, 2025 18:52
@hectahertz hectahertz requested a review from camertron January 8, 2025 18:52
Copy link

changeset-bot bot commented Jan 8, 2025

🦋 Changeset detected

Latest commit: e723e40

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 8, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jan 8, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-5504 January 8, 2025 18:55 Inactive
Copy link
Contributor

github-actions bot commented Jan 8, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 104.2 KB (+0.03% 🔺)
packages/react/dist/browser.umd.js 104.49 KB (-0.03% 🔽)

@hectahertz hectahertz changed the title Hectahertz/pagination algorithm enhancements Pagination algorithm enhancements Jan 8, 2025
@hectahertz hectahertz force-pushed the hectahertz/pagination-algorithm-enhancements branch from 5a2568a to 321642a Compare January 10, 2025 15:55
@github-actions github-actions bot temporarily deployed to storybook-preview-5504 January 10, 2025 15:59 Inactive
@francinelucca francinelucca force-pushed the hectahertz/pagination-algorithm-enhancements branch from 2b47044 to c1d1901 Compare January 10, 2025 20:53
@hectahertz hectahertz added this pull request to the merge queue Jan 16, 2025
Merged via the queue into main with commit 9986d67 Jan 16, 2025
42 checks passed
@hectahertz hectahertz deleted the hectahertz/pagination-algorithm-enhancements branch January 16, 2025 18:02
@primer primer bot mentioned this pull request Jan 16, 2025
@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/358229

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jan 16, 2025
camertron added a commit that referenced this pull request Jan 16, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jan 16, 2025
francinelucca added a commit that referenced this pull request Jan 16, 2025
@primer-integration
Copy link

🔴 golden-jobs completed with status failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: failing Changes in this PR cause breaking changes in gh/gh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants