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

[List] Add support for list item container style overrides #25777

Merged
merged 13 commits into from
Apr 16, 2021

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Apr 15, 2021

This PR adds the support for adding style overrides for the container inside the ListItem.

Also fixes #25774

@mui-pr-bot
Copy link

mui-pr-bot commented Apr 15, 2021

Details of bundle changes

Generated by 🚫 dangerJS against e174ced

@oliviertassinari oliviertassinari added the component: list This is the name of the generic UI component, not the React module! label Apr 15, 2021
@oliviertassinari oliviertassinari changed the title [ListItem] Add support for container style overrides [List] Add support for list item container style overrides Apr 15, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

In #13597 we discuss changing the structure. Basically, it's not OK to change the root dynamically (since v1). It's magical. Does taking this issue into account, and more specifically the flattening direction change the outcome of this PR?

I mean, was:

diff --git a/packages/material-ui/src/ListItem/ListItem.js b/packages/material-ui/src/ListItem/ListItem.js
index d06a7edc18..ae25d6df7b 100644
--- a/packages/material-ui/src/ListItem/ListItem.js
+++ b/packages/material-ui/src/ListItem/ListItem.js
@@ -151,7 +151,7 @@ const ListItemContainer = experimentalStyled(
   {
     name: 'MuiListItem',
     slot: 'Container',
-    overridesResolver,
+    overridesResolver: (props, styles) => styles.container,
   },
 )({
   position: 'relative',

considered as an option for the solution?

@mnajdova
Copy link
Member Author

In #13597 we discuss changing the structure. Basically, it's not OK to change the root dynamically. It's magical. Does taking this issue into account, and more specifically the flattening direction change the outcome of this PR?

I mean, was:

index d06a7edc18..ae25d6df7b 100644
--- a/packages/material-ui/src/ListItem/ListItem.js
+++ b/packages/material-ui/src/ListItem/ListItem.js
@@ -151,7 +151,7 @@ const ListItemContainer = experimentalStyled(
   {
     name: 'MuiListItem',
     slot: 'Container',
-    overridesResolver,
+    overridesResolver: (props, styles) => styles.container,
   },
 )({
   position: 'relative',

considered as an option for the solution?

I haven't thought of this, mainly because it kind of validates the CSS structure that I had in mind. My thinking was that it is unintuitive to define styles in a component that is a child of another. On the other hand, we won't have breaking changes with the proposed fix, plus it doesn't require the developers to have knowledge of the internal structure of the component. Let me update.

@mnajdova mnajdova merged commit cef6076 into mui:next Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: list This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ListItem] Having styleOverrides key brokes component
4 participants