fix(Dialog): forward id, data-testid, and other unknown attributes to root element - #8252
Draft
siddharthkp wants to merge 1 commit into
Draft
fix(Dialog): forward id, data-testid, and other unknown attributes to root element#8252siddharthkp wants to merge 1 commit into
siddharthkp wants to merge 1 commit into
Conversation
Contributor
|
|
Integration test results from github/github-ui PR:
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a regression where the stable
Dialogsilently droppedid,data-testid, and every other arbitrary DOM/aria-*/data-*attribute passed to it.DialogPropswas a closed interface and the rootrole="dialog"element was assembled from a hand-picked attribute list that never spread the remaining props, so migrating from the deprecatedDialog(which forwarded these) broke any test or integration that located the dialog bygetByTestId(...)or byid, with no compile-time signal.Now
DialogPropsextendsReact.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
Dialognow forwardsid,data-testid, and other unrecognized DOM/aria-*/data-*attributes to the rootrole="dialog"element, matching the deprecatedDialogand other Primer components.Rollout strategy
Testing & Reviewing
A unit test in
Dialog.test.tsxverifies thatid,data-testid,data-*, andaria-*attributes land on the root dialog element. Manually verify with:screen.getByTestId('my-dialog')anddocument.getElementById('my-dialog')now resolve to the root dialog element.