Skip to content

Conversation

joshblack
Copy link
Member

Closes #6762

Changelog

New

Changed

  • Refactor usage of Box internally from @mperrotti's work
  • Update tests in styled-react to account for sx usage in Dialog sub-components

Removed

  • Remove support for sx from Dialog

Rollout strategy

  • Major release; if selected, include a written rollout or migration plan

We will use the @primer/styled-react package to update usage downstream before rolling this change out

@Copilot Copilot AI review requested due to automatic review settings September 9, 2025 17:04
@joshblack joshblack requested a review from a team as a code owner September 9, 2025 17:04
@joshblack joshblack requested a review from jonrohan September 9, 2025 17:04
Copy link

changeset-bot bot commented Sep 9, 2025

🦋 Changeset detected

Latest commit: b3b1712

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

This PR includes changesets to release 2 packages
Name Type
@primer/react Major
@primer/styled-react Major

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

@github-actions github-actions bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Sep 9, 2025
Copy link
Contributor

github-actions bot commented Sep 9, 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!

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 support for the sx prop from the Dialog component and its sub-components as part of a major version release. The change aims to simplify the Dialog API by removing styled-system integration while maintaining backward compatibility through the @primer/styled-react package.

  • Removes sx prop support from Dialog, Dialog.Header, Dialog.Title, Dialog.Subtitle, Dialog.Body, and Dialog.Footer
  • Refactors internal usage of Box component to native HTML elements with CSS modules
  • Creates a styled-react wrapper to maintain sx support for consumers during migration

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/styled-react/src/sx.ts Adds utility function for styled-system CSS processing
packages/styled-react/src/index.tsx Updates exports to include Dialog from styled-react package
packages/styled-react/src/experimental.tsx Re-exports Dialog from local implementation instead of @primer/react
packages/styled-react/src/components/Dialog.tsx Implements Dialog wrapper with sx support using styled-components
packages/styled-react/src/tests/primer-react.browser.test.tsx Adds tests for Dialog sub-components with sx prop support
packages/react/src/Dialog/Dialog.tsx Removes sx prop and Box usage, replaces with native HTML elements
packages/react/src/Dialog/Dialog.module.css Adds CSS classes for header layout previously handled by Box
.changeset/sweet-results-smell.md Documents breaking change for major version release

Comment on lines 21 to 22
// @ts-expect-error - PrimerDialog.Header is not recognized as a valid component type
return <Wrapper as={PrimerDialog.Header} ref={ref} {...props} />
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The TypeScript error suppression indicates a potential issue with the component typing. Consider properly typing the PrimerDialog sub-components or creating a more robust wrapper that doesn't require error suppression.

Copilot uses AI. Check for mistakes.

Comment on lines 26 to 27
// @ts-expect-error - PrimerDialog.Body is not recognized as a valid component type
return <Wrapper as={PrimerDialog.Body} ref={ref} {...props} />
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The TypeScript error suppression indicates a potential issue with the component typing. Consider properly typing the PrimerDialog sub-components or creating a more robust wrapper that doesn't require error suppression.

Copilot uses AI. Check for mistakes.

Comment on lines 31 to 32
// @ts-expect-error - PrimerDialog.Footer is not recognized as a valid component type
return <Wrapper as={PrimerDialog.Footer} ref={ref} {...props} />
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The TypeScript error suppression indicates a potential issue with the component typing. Consider properly typing the PrimerDialog sub-components or creating a more robust wrapper that doesn't require error suppression.

Copilot uses AI. Check for mistakes.

Comment on lines 352 to 353
// TODO: get rid of typecasting `forwardRef`
const Title = React.forwardRef<HTMLHeadingElement, StyledTitleProps>(function Title({className, ...rest}, forwardRef) {
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The TODO comment suggests this is temporary code. Consider addressing the type casting issue or creating a tracking issue if this needs to be resolved in a future iteration.

Suggested change
// TODO: get rid of typecasting `forwardRef`
const Title = React.forwardRef<HTMLHeadingElement, StyledTitleProps>(function Title({className, ...rest}, forwardRef) {
const Title = React.forwardRef<HTMLHeadingElement, StyledTitleProps>(function Title(
{className, ...rest},
forwardRef: React.ForwardedRef<HTMLHeadingElement>,
) {

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is just a comment I forgot to delete. Go ahead and remove it.

Copy link
Contributor

github-actions bot commented Sep 9, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 89.44 KB (-0.2% 🔽)
packages/react/dist/browser.umd.js 89.6 KB (+0.04% 🔺)

Comment on lines 5 to 6
Dialog as PrimerDialog,
type DialogProps as PrimerDialogProps,
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by what's happening here too 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the error is because we moved those imports to components/Dialog and forgot to remove from here.

Copy link
Contributor

@mperrotti mperrotti left a comment

Choose a reason for hiding this comment

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

Changes look good overall. Approved assuming you'll:

  • fix the broken "default" story VRT that was broken by removing Dialog sx props
  • remove the Dialog stories that use the sx prop
  • fix the linting errors

Copy link
Contributor

@mperrotti mperrotti left a comment

Choose a reason for hiding this comment

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

oops, forgot to select "Approve" radio

@mperrotti mperrotti added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 12, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6812 September 12, 2025 17:46 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-6812 September 12, 2025 17:54 Inactive
@mperrotti mperrotti added update snapshots 🤖 Command that updates VRT snapshots on the pull request and removed update snapshots 🤖 Command that updates VRT snapshots on the pull request labels Sep 12, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6812 September 12, 2025 18:29 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 Sep 15, 2025
@joshblack joshblack removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 16, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6812 September 16, 2025 22:17 Inactive
@github-actions github-actions bot requested a deployment to storybook-preview-6812 September 16, 2025 22:39 Abandoned
@github-actions github-actions bot requested a deployment to storybook-preview-6812 September 16, 2025 22:46 Abandoned
@primer-integration
Copy link

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

@primer-integration
Copy link

🔴 ci 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 staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove support for sx from the Dialog component
4 participants