Skip to content

Conversation

@francinelucca
Copy link
Member

Closes https://github.com/github/primer/issues/5577

The Dialog component is coded to render its own Default subcomponents if render* functions aren't provided. Because the Dialog is not looking at its children to determine wether Dialog.Body, Dialog.Header, Dialog.Footer are present, it can 'cause a Dialog.Body to be wrapped inside the DefaultDialogBody, causing duplication of classes/padding. This PR adds useSlots to prefer rendering direct children over default wrappers.

Changelog

New

  • Adds _SLOT_ symbols to Dialog and subcomponents in @primer/react and @primer/styled-react
  • Adds Dialog story using direct children

Changed

  • use slots in Dialog to detect direct children and avoid double wrappers

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 AI review requested due to automatic review settings October 23, 2025 03:18
@francinelucca francinelucca requested a review from a team as a code owner October 23, 2025 03:18
@changeset-bot
Copy link

changeset-bot bot commented Oct 23, 2025

🦋 Changeset detected

Latest commit: 47e492e

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 Patch
@primer/styled-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

@francinelucca francinelucca requested review from hectahertz and joshblack and removed request for Copilot and siddharthkp October 23, 2025 03:18
@github-actions github-actions bot added the staff Author is a staff member label Oct 23, 2025
@github-actions
Copy link
Contributor

👋 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 Oct 23, 2025
},
[onClose, lastMouseDownIsBackdrop],
)
const [slots] = useSlots(props.children, {body: Dialog.Body, header: Dialog.Header, footer: Dialog.Footer})
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not in love with the idea of adding more slots to the codebase so open to suggestions here...

Copilot AI review requested due to automatic review settings October 23, 2025 03:21
Copy link
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 fixes a bug in the Dialog component where direct children (Dialog.Header, Dialog.Body, Dialog.Footer) would be wrapped inside default wrappers, causing duplicate classes and padding. The solution implements a slot-based system using useSlots to detect and prefer direct children over default renderers.

Key Changes:

  • Introduces __SLOT__ symbols to Dialog and its subcomponents for identification
  • Implements useSlots hook to detect direct children and prioritize them over default wrappers
  • Adds a new Storybook story demonstrating direct children usage

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react/src/Dialog/Dialog.tsx Implements slot detection logic and adds slot symbols to Dialog components
packages/styled-react/src/components/Dialog.tsx Propagates slot symbols from primer/react to styled-react wrapper components
packages/react/src/Dialog/Dialog.features.stories.tsx Adds story demonstrating direct subcomponent usage
e2e/components/Dialog.test.ts Adds e2e test coverage for the new direct subcomponents story
.changeset/loud-trainers-drop.md Documents the change as a patch release

@github-actions github-actions bot requested a deployment to storybook-preview-7060 October 23, 2025 03:25 Abandoned
@francinelucca francinelucca added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 23, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-7060 October 23, 2025 03:33 Inactive
@primer primer bot requested a review from a team as a code owner October 23, 2025 03:43
@primer primer bot requested a review from langermank October 23, 2025 03:43
@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 23, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-7060 October 23, 2025 03:52 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 Oct 23, 2025
@primer-integration
Copy link

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

Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

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

🚀

@github-actions github-actions bot requested a deployment to storybook-preview-7060 October 30, 2025 03:52 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-7060 October 30, 2025 04:00 Inactive
@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 Oct 30, 2025
Copy link
Contributor

@hectahertz hectahertz left a comment

Choose a reason for hiding this comment

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

🚀

@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 Oct 30, 2025
@github-actions
Copy link
Contributor

👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks!

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Oct 30, 2025
@primer-integration
Copy link

🟢 ci 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 Oct 30, 2025
@francinelucca francinelucca added this pull request to the merge queue Oct 30, 2025
Merged via the queue into main with commit 3468793 Oct 30, 2025
42 checks passed
@francinelucca francinelucca deleted the chore/dialog-allow-direct-children branch October 30, 2025 16:02
@primer primer bot mentioned this pull request Oct 30, 2025
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 staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants