Skip to content

Remove the CSS modules feature flag from Pagination component #5997

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

Merged
merged 7 commits into from
May 9, 2025

Conversation

jamieshark
Copy link
Contributor

Changelog

New

Changed

Removed

CSS modules feature flag from Pagination component

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

Merge checklist

@Copilot Copilot AI review requested due to automatic review settings May 4, 2025 14:35
@jamieshark jamieshark requested a review from a team as a code owner May 4, 2025 14:35
@jamieshark jamieshark requested a review from joshblack May 4, 2025 14:35
Copy link

changeset-bot bot commented May 4, 2025

🦋 Changeset detected

Latest commit: 8c53016

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 Minor

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

@jamieshark jamieshark self-assigned this May 4, 2025
@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 May 4, 2025
Copy link
Contributor

github-actions bot commented May 4, 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!

@@ -196,53 +68,22 @@ function usePaginationPages({
}

return (
<Page {...props} key={key} theme={theme} className={clsx(enabled && classes.Page)}>
<span {...props} key={key} className={clsx(classes.Page)}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this should have been an a tag based on the previous code, but that caused a test to fail with the expected number of a tags to render. Not sure if the test had to be updated, or if this is the correct default element.

Copy link
Contributor

@Copilot 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 removes the legacy CSS modules feature flag from the Pagination component and replaces the styled‑components implementation with CSS module classes and a toggleable SX component.

  • Removed toggleStyledComponent, styled-components imports, useFeatureFlag, and theme props
  • Replaced custom <Page> styled anchor with a <span> using CSS module classes
  • Swapped toggleStyledComponent for toggleSxComponent on the container and always apply CSS module classes via className

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/Pagination/Pagination.tsx Remove styled‑components and feature flag, apply CSS modules classes, update container to SX component
.changeset/nasty-nails-appear.md Update changelog to reflect removal of CSS modules flag

Comment on lines 71 to 73
<span {...props} key={key} className={clsx(classes.Page)}>
{content}
</Page>
</span>
Copy link
Preview

Copilot AI May 4, 2025

Choose a reason for hiding this comment

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

Replacing the styled anchor component with a removes native anchor semantics (e.g., href support, keyboard focus, and accessibility). Consider rendering an or using a component that preserves the original element type via the as prop.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

github-actions bot commented May 4, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 97.96 KB (-0.6% 🔽)
packages/react/dist/browser.umd.js 98.22 KB (-0.55% 🔽)

Comment on lines 81 to 83
const PaginationContainer = toggleSxComponent('nav') as React.ComponentType<
React.HTMLAttributes<HTMLElement> & SxProp & React.PropsWithChildren
>
Copy link
Member

Choose a reason for hiding this comment

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

One option for these is to use BoxWithFallback directly where the component is used since we don't really need these wrappers anymore. For example:

// Before
  return (
    <PaginationContainer
      className={clsx(enabled && classes.PaginationContainer)}
      aria-label="Pagination"
      {...rest}
      theme={theme}
    >

// After
  return (
    <BoxWithFallback
      as="nav"
      className={clsx(enabled && classes.PaginationContainer)}
      aria-label="Pagination"
      {...rest}
    >

Let me know what you think!


export type PaginationProps = {
theme?: Record<string, unknown>
Copy link
Member

Choose a reason for hiding this comment

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

I think if we're exposing theme / it's in our Public API we should add a deprecation note here for this type and then update the usage below to noop like:

function Pagination({
  theme: _theme,

This will help out when rolling this out to avoid:

  • A TypeScript error with theme being provided (but it's no longer on the type)
  • A runtime error if theme is now added to the element that {...rest} is being called on since it would be in the rest argument

Hope that makes sense, let me know what you think! If all of this is internal feel free to ignore me too 😂

@jamieshark jamieshark requested a review from joshblack May 7, 2025 19:57
@github-actions github-actions bot temporarily deployed to storybook-preview-5997 May 7, 2025 20:11 Inactive
@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 May 7, 2025
@primer-integration
Copy link

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

@primer-integration
Copy link

🟢 golden-jobs completed with status success.

@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels May 8, 2025
@joshblack joshblack added this pull request to the merge queue May 9, 2025
Merged via the queue into main with commit 882d923 May 9, 2025
35 checks passed
@joshblack joshblack deleted the remove-css-modules-ff/pagination branch May 9, 2025 15:44
@primer primer bot mentioned this pull request May 9, 2025
jonrohan pushed a commit that referenced this pull request May 9, 2025
Co-authored-by: Marie Lucca <40550942+francinelucca@users.noreply.github.com>
jonrohan pushed a commit that referenced this pull request May 9, 2025
Co-authored-by: Marie Lucca <40550942+francinelucca@users.noreply.github.com>
hectahertz pushed a commit that referenced this pull request May 20, 2025
Co-authored-by: Marie Lucca <40550942+francinelucca@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants