-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[RFC] ListItem improvement #26442
Comments
This comment has been minimized.
This comment has been minimized.
I would vote for Solution I, it doesn't have any magic behind it, and with good docs demos, developers shouldn't have any problems implementing it. |
I would vote for Solution I. To keep customizations as simple as possible. Regarding the cons.
I think that the audience that doesn't know the correct markup is also the audience that copy and paste the demos a lot, so it doesn't matter. The audience that knows the correct markup will be destabilized by seeing a component host two DOM nodes.
Agree, best to avoid negative margin, it can be destabilizing. |
I could live with either but think that solution 2 reduces boilerplate code and makes the simple usage scenario (no customisation) quicker to implement, so my vote goes there. |
I think that the framing in this RFC's description misses an important dimension. How do we make the item interactive? It either need a click listener as a button or a With Solution I: <List>
<ListItem>
<ListItemButton component={Link} to="/foo">
</ListItemButton>
</ListItem>
</List> With Solution II, we need to take #21453, we need: <List>
<ListItemButton componentsProps={{ button: { component: 'a', href: '#id' } }}>
</ListItemButton>
</List> If we render a link, or if we render a button <List>
<ListItemButton componentsProps={{ button: { onClick: handleClick } }}>
</ListItemButton>
</List> |
What do you propose without using negative margin in this case (and without js to check)? <ListItem>
<ListItemButton>
Some text
</ListItemButton>
</ListItem> Can it be something explicit by user? <ListItem disablePadding>
<ListItemButton>
Some text
</ListItemButton>
</ListItem> |
@siriwatknp No preferences, we could try with a negative magin. I was simply confirming your point, that it's not awesome. |
To push this forward, I suggest we go with solution 1 for v5 and keep an eyes for related API issues
I suggest to not spend too much time (it's been over a week already) on this because both ways are far better than the |
Sounds good 👍 |
Problem
Regarding to #13597
The implementation of
ListItem
is complex to understand and does too many things that developers does not expect.render
ListItemSecondaryAction
insideListItem
cause the markup to changeThis cause a lot of confusion to developer. Moreover, the
ContainerProps
is added for customization which add more API for the developer to know.when
button
prop is true,ButtonBase
is used which change the default tag ofListItem
, again cause confusion and developer needs to know the implementation detailFrequently, the
ListItem
is override bya
orLink
from router library. Developer needs to know to wrap withli
Goal
List components tends to be used to create new component like nested menu, link item, and many more. So, material-ui should provide the list components that are styled with material design spec and simple to compose together without needing to know much about the implementation.
container
propsSolution I : One element, One DOM #26446
From comments and issues, one way to improved is to extract
button
out ofListItem
so each component render only single markupPros
Button
Cons
ListItem
andListItemButton
together require nested CSS & negative margin. (customise padding will require negative margin adjustment)Solution II : Flat ListItemButton #26480
ListItemButton
always render 2 DOM, by default<li> <div>
Pros
Cons
componentsProps
Secondary Action
Both solutions will use the same API for handling secondary action. Regardless of the approach,
ListItem
andListItemButton
acceptsecondaryAction
prop.This will remove the hidden logic to check if children has
ListItemSecondaryAction
or not.Breaking change?
Instead of making this as
breaking change
, I prefer to adjustListItem
and mark some prop likebutton
as deprecated and then remove them in next major version because I assume that most of the project useListItem
in some way.Further
from @eps1lon suggestion, it is nice to expose
UnorderedList
andOrderedList
as a wrapper ofListItem
like Chakra-UI does.cc @mui-org/core
The text was updated successfully, but these errors were encountered: