-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGrid] Spread forwardedProps onto grid element #14197
Conversation
Deploy preview: https://deploy-preview-14197--material-ui-x.netlify.app/ |
…lement
00063b7
to
a5c719c
Compare
@michelengelen Any reviews on this would be great. |
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.
Not sure what to think of this one. The change makes sense, but I think this could also be considered a breaking change at this point.
@mui/xgrid Thoughts?
Update: strikeout because of #8525 |
I've read the issue again and I think this could also classify as a bug. It's a breaking behavior that wasn't intended nor documented in the changelog, and it causes a11y issues. I think I'd be fine with merging the PR. |
I think that the fact that even in this PR a test had to be updated to target the right element shows that we should treat it as a breaking change. To update on my previous comment
Actually, the only way to deal with this is like in this PR (moving forwarded props down), because |
I guess it would also be possible to introduce a new prop that targets the By the way the prop is marked as undocumented, we should remove that mui-x/packages/x-data-grid/src/models/props/DataGridProps.ts Lines 389 to 392 in c0463fd
|
For context, I'm still on v6 as the migration to v7 breaks tests duo to the It is unfortunate that the changes in this PR are a breaking change on top of the v6 to v7 breaking change, but sounds like the right direction to go. |
Agreed, to avoid the breaking change, we could add a temporary separate prop like |
But it could also be a different prop like |
There might be, I haven't seen it yet though. For simplicity, maybe start with only the grid element and aim to reintroduce it on the root element if there's a clear need. Wdyt? |
I'm fine with that. |
@MBilalShafi No problem, If you could take over the changes, that would be great. We can close this PR and start again if that's easier. |
I would favor adding |
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.
Break API convention / describeConformance()
, extra props should land on the root element, it's not the case https://deploy-preview-14197--material-ui-x.netlify.app/x/react-data-grid/

As I understand WAI-ARIA Authoring Practices, extra attributes like aria-label, aria-describedby, etc. should be applied to the element with role="grid" for the screen readers to properly associate these attributes with the grid functionality. I understand that we have an API convention to spread the extra props on to the DOM root element, this case seems to be an exception though as we can't move What do you think about considering the logical root element ( An additional prop |
@MBilalShafi I think this is where the |
I agree. This is the least confusing option.
I'm in favor of option 1. |
@cherniavskii Another option could be to follow a similar route as #10409 (comment), i.e. stop forwarding additional props forwarded on the Summing up, we have the following options to choose from.
If I get it right, your suggestion is option 1, I proposed option 2, it seems option 3 could be the least confusing middle-ground. Wdyt? |
This only applies to |
Yes, only the forwarded props prefixed with |
Then option 3 sounds good to me 👍🏻 |
The simplicity of just providing the 'aria-' prop to the component and it just works with screen readers is nice. But option 3 allows flexibility to enable any use case so sounds good 👍 |
For sure 1. no question, we have to keep the pattern consistent (class name slot name) for people to learn things once. If the aria role is important, then we can argue that
If we mean we can get rid of all of this:
With compound components, we could improve the DX later on, while still making the current one-component API behavior easy to predict. |
Raised a follow-up PR based on the discussion above: #15870 When that is merged, we could close this one safely. Thank you everyone for your input 🙇 |
Closes #13522
Looking at the historical changes, the
aria-*
anddata-*
props were originally on theGridRoot
component when it had the role of "grid". This PR moves therootProps.forwardedProps
back to that element which has moved into theGridMainContainer
component.Demo: https://codesandbox.io/p/sandbox/github/samwato/codesandbox/tree/main/mui-x-issue-13522