-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Is there a reason ListItemSecondaryAction is absolutley positioned? #13495
Comments
@Pajn Yes, it's because HTML5 specification prohibits the nesting of |
@Pajn You are right, I have jumped to the conclusion too quickly. I think that it's important to have a ripple covering the whole surface area. In order to have that, we need to nest the secondary action in the list or to absolutely position the action. If we go with the nesting path, it's important to be careful with the resulting DOM structure, some combinations are invalid. Benchmarking MCW and vuetify it seems we are the only one doing that. I have nothing against exploring the flex layout position path. It's definitely a breaking change, we would have to wait for v4.0.0, coming in the next few months. Feel free to experiment, I think that it will be a success if:
|
I tried this long ago and we merged #5911 but reverted due to the ripple issue. I did try to revisit this, I still have the branch https://github.com/alienfast/material-ui/tree/list-item-flex-revisited - I tried with a ripple bounding element but I did not have success. I just bumped into this again - am using a ListItem without |
I'm closing for #13597 that explores how to improve the ListItemSecondaryAction position. |
Use a scary method to patch it const buttonRef = useRef<HTMLElement>(null)
const listRef = useRef<HTMLDivElement>(null)
useLayoutEffect(() => {
if (!buttonRef.current || !listRef.current) return
const width = buttonRef.current.getBoundingClientRect().width
const child = listRef.current.children[0]
if (!child) return
;(child as HTMLElement).style.paddingRight = `${width + 10}px`
}) |
@Jack-Works If the container isn't a button, I would personally trash the usage of the |
Expected Behavior
I just run into #8205 for the nth time and my fix is always the same, make ListItemSecondaryAction staticly positioned, make the list item container a flexbox and undo the additional padding.
It would be nice if this was not necessary and instead the default behavior.
Current Behavior
The ListItemSecondaryAction is absolutely positioned, causing the problem that it does not grow to take the space needed for its content.
Examples
N/A
Context
I think this is described with enough context above.
The text was updated successfully, but these errors were encountered: