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

Cannot use wrapper for ListItemSecondaryAction #11622

Closed
2 tasks done
stefan-dimitrov opened this issue May 29, 2018 · 4 comments
Closed
2 tasks done

Cannot use wrapper for ListItemSecondaryAction #11622

stefan-dimitrov opened this issue May 29, 2018 · 4 comments
Labels
support: question Community support but can be turned into an improvement

Comments

@stefan-dimitrov
Copy link

  • This is a v1.x issue (v0.x is no longer maintained).
  • I have searched the issues of this repository and believe that this is not a duplicate.

Similar to #11231

Expected Behavior

  • When using a wrapper component of the ListItemSecondaryAction in the list item:

    When hovering over the list item body, the whole list item is highlighted:
    screenshot from 2018-05-29 10-25-30

    When hovering over the button(secondary action), only the button is highlighted:
    screenshot from 2018-05-29 10-24-35

    When clicking the button(secondary action), only the button receives the click event.

Current Behavior

When hovering over the button(secondary action), both the list item and the button are highlighted:
screenshot from 2018-05-29 10-32-25

When clicking the button(secondary action), both the list item and the button receive the click event.

Steps to Reproduce (for bugs)

  1. Go to https://codesandbox.io/s/3xy267156p
  2. Hover over the button on the right of the list item, click it. You notice how both the button and the list item are highlighted on hover and when clicked both display the ripple effect, indicating they have both received the click event.
    • If you replace the usage of SecondaryActionWrapper with the ListItemSecondaryAction(demo.js), all should work normally as in the official demo: https://codesandbox.io/s/006wj9mnkn

Context

Your Environment

Tech Version
Material-UI v1.1.0
React v16.4.0
browser Firefox 60.0.1, Chromium 66.0.3359.181, Chrome 66.0.3359.181
@oliviertassinari oliviertassinari added the support: question Community support but can be turned into an improvement label May 29, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented May 29, 2018

Following the documentation, this fix the issue :)

// Wrapper of ListItemSecondaryAction
const SecondaryActionWrapper = ({ ...props  }) => <ListItemSecondaryAction {...props} />

+SecondaryActionWrapper.muiName = "ListItemSecondaryAction";

@stefan-dimitrov
Copy link
Author

That works, thank you @oliviertassinari !

@montiquewillis
Copy link

montiquewillis commented Sep 11, 2018

@oliviertassinari Hello, I'm new to using react and not understanding the solution. I'm running into this same issue after following the documentation.Props are defined on the parent component. Is this the correct approach? I'm still unable to click the secondary action without triggering the link.

render(){
     const SecondaryActionWrapper = ({ ...props  }) => <ListItemSecondaryAction {...props} />
      SecondaryActionWrapper.muiName = "ListItemSecondaryAction";
     return(
          <ListItem dense button component={this.renderLink}>
                  <ListItemText inset style= {{fontSize: 12}} primary={data.title}/>
                  {icon && <SecondaryActionWrapper>{icon}</SecondaryActionWrapper>}
           </ListItem>
 )
}

@oliviertassinari
Copy link
Member

@montiquewillis It should be working. If you have a live reproduction example, on Codesandbox for instance, you can open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

3 participants