Skip to content
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] Use slotProps to forward props to .main and .root elements #15870

Merged
merged 8 commits into from
Dec 16, 2024

Conversation

MBilalShafi
Copy link
Member

@MBilalShafi MBilalShafi commented Dec 13, 2024

Closes #13522
Closes #14197

Continuation of #14197, thank you @samwato for the original PR.

Motivation for the approach followed: #14197 (comment)

Changelog

Breaking changes

  • Passing additional props (like data-*, aria-*) directly on the Data Grid component is no longer supported. To pass the props, use slotProps.
    • For .root element, use slotProps.root
    • For .main element (the one with role="grid"), use slotProps.main

@MBilalShafi MBilalShafi added accessibility a11y component: data grid This is the name of the generic UI component, not the React module! labels Dec 13, 2024
@mui-bot
Copy link

mui-bot commented Dec 13, 2024

Copy link
Member Author

@MBilalShafi MBilalShafi Dec 13, 2024

Choose a reason for hiding this comment

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

Open Question

How to port this to v7? If we treat #13522 as bug, we could port it as it is, as a bug fix.

However, since the discussion here emphasizes it to be a breaking change. To avoid it, we could only introduce slotProps.main and keep the current behavior of passing the props to the .root element, to at least have a workaround for the v7 users wanting to target (role="grid") element.

We could then make it part of the v7 -> v8 migration guide to connect the dots.

Any objections @mui/xgrid ?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with keeping props forwarding for v7 👍🏻
However, I would also add slotProps.root, and if it is provided – skip the forwarding logic in useProps.

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds even better. 👍

Copy link
Member

Choose a reason for hiding this comment

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

I agree with keeping props forwarding for v7 👍🏻
However, I would also add slotProps.root, and if it is provided – skip the forwarding logic in useProps.

@MBilalShafi MBilalShafi enabled auto-merge (squash) December 16, 2024 12:59
@MBilalShafi MBilalShafi merged commit 4a94c32 into mui:master Dec 16, 2024
16 checks passed
@MBilalShafi MBilalShafi deleted the refactor-forwarded-props branch December 16, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y breaking change component: data grid This is the name of the generic UI component, not the React module! v8.x
Projects
None yet
3 participants