-
Notifications
You must be signed in to change notification settings - Fork 646
chore(Dialog): allow direct children #7060
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
Conversation
🦋 Changeset detectedLatest commit: 47e492e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
|
👋 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! |
packages/react/src/Dialog/Dialog.tsx
Outdated
| }, | ||
| [onClose, lastMouseDownIsBackdrop], | ||
| ) | ||
| const [slots] = useSlots(props.children, {body: Dialog.Body, header: Dialog.Header, footer: Dialog.Footer}) |
There was a problem hiding this comment.
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...
There was a problem hiding this 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
useSlotshook 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 |
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/5505 |
langermank
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
hectahertz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
…r/react into chore/dialog-allow-direct-children
|
👋 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! |
|
🟢 ci completed with status |
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
_SLOT_symbols to Dialog and subcomponents in @primer/react and @primer/styled-reactChanged
Rollout strategy
Testing & Reviewing
Merge checklist