Skip to content

fix(Dialog): forward id, data-testid, and other unknown attributes to root element - #8252

Draft
siddharthkp wants to merge 1 commit into
mainfrom
fix-dialog-forward-props
Draft

fix(Dialog): forward id, data-testid, and other unknown attributes to root element#8252
siddharthkp wants to merge 1 commit into
mainfrom
fix-dialog-forward-props

Conversation

@siddharthkp

@siddharthkp siddharthkp commented Jul 30, 2026

Copy link
Copy Markdown
Member

Fixes a regression where the stable Dialog silently dropped id, data-testid, and every other arbitrary DOM/aria-*/data-* attribute passed to it. DialogProps was a closed interface and the root role="dialog" element was assembled from a hand-picked attribute list that never spread the remaining props, so migrating from the deprecated Dialog (which forwarded these) broke any test or integration that located the dialog by getByTestId(...) or by id, with no compile-time signal.

Now DialogProps extends React.ComponentPropsWithoutRef<'div'> (omitting the keys it intentionally narrows: title, role, onClose) and the component spreads unrecognized props onto the root dialog element. Component-controlled attributes (role, data-width, data-height, className, style, data-component, position data attributes) still take precedence.

Changelog

Changed

  • Dialog now forwards id, data-testid, and other unrecognized DOM/aria-*/data-* attributes to the root role="dialog" element, matching the deprecated Dialog and other Primer components.

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

A unit test in Dialog.test.tsx verifies that id, data-testid, data-*, and aria-* attributes land on the root dialog element. Manually verify with:

<Dialog title="Example" onClose={noop} data-testid="my-dialog" id="my-dialog" />

screen.getByTestId('my-dialog') and document.getElementById('my-dialog') now resolve to the root dialog element.

@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 Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Failed  CI   Failed
Passed  VRT   Passed
Passed  Projects   Passed

CI check runs linting, type checking, and unit tests. Check the workflow logs for specific failures.

Need help? If you believe this failure is unrelated to your changes, please reach out to the Primer team for assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant