Skip to content

[DataGrid] Use slotProps to forward props to .main and .root elements#15870

Merged
MBilalShafi merged 8 commits intomui:masterfrom
MBilalShafi:refactor-forwarded-props
Dec 16, 2024
Merged

[DataGrid] Use slotProps to forward props to .main and .root elements#15870
MBilalShafi merged 8 commits intomui:masterfrom
MBilalShafi:refactor-forwarded-props

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 scope: data grid Changes related to the data grid. 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. 👍

@MBilalShafi MBilalShafi requested a review from a team December 13, 2024 08:00
@MBilalShafi MBilalShafi added breaking change Introduces changes that are not backward compatible. v8.x labels Dec 13, 2024
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 and others added 4 commits December 13, 2024 18:17
Co-authored-by: Andrew Cherniavskii <andrew.cherniavskii@gmail.com>
Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
@MBilalShafi MBilalShafi enabled auto-merge (squash) December 16, 2024 12:59
@MBilalShafi MBilalShafi merged commit 4a94c32 into mui:master Dec 16, 2024
@MBilalShafi MBilalShafi deleted the refactor-forwarded-props branch December 16, 2024 13:36
lauri865 pushed a commit to lauri865/mui-x that referenced this pull request Dec 19, 2024
…ements (mui#15870)

Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
Co-authored-by: Andrew Cherniavskii <andrew.cherniavskii@gmail.com>
LukasTy pushed a commit to LukasTy/mui-x that referenced this pull request Dec 19, 2024
…ements (mui#15870)

Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
Co-authored-by: Andrew Cherniavskii <andrew.cherniavskii@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility a11y breaking change Introduces changes that are not backward compatible. scope: data grid Changes related to the data grid. v8.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[data grid] The provided aria label prop is attached on the wrong grid element, causing issues with accessibility

3 participants