tleunen / react-mdl

React Components for Material Design Lite
https://tleunen.github.io/react-mdl/
MIT License
1.76k stars 255 forks source link

Allow children in ListItemAction #329

Closed adamdawkins closed 8 years ago

adamdawkins commented 8 years ago

Hey.

I've added a Menu to the ListItemAction, which feels like a valid use, but I'm getting the warning that

warning.js:44 Warning: Failed propType: Invalid propchildrensupplied toListItemAction, expected a single ReactElement. Check the render method ofEmployeeListItem`.

I'm passing in an IconButton and a Menu, like so:

...   
 <ListItemAction>
      <IconButton name="more_vert" id={`menu-${employee._id}`} />
      <Menu target={`menu-${employee._id}`} align="right">
        <MenuItem>Record uniform transaction</MenuItem>
        <MenuItem>Record uniform refund</MenuItem>
        <MenuItem disabled>Edit employee</MenuItem>
        <MenuItem disabled>Remove employee from this store</MenuItem>
      </Menu>

    </ListItemAction>
...

Is there a reason this shouldn't be allowed?

tleunen commented 8 years ago

Hmm.. You're right. Initially we did that to limit the content to a single item. But with the current state of the menu, it's not compatible :s

A PR is welcome to address this issue. Should be trivial. Probably just need to remove this: https://github.com/tleunen/react-mdl/blob/master/src/List/ListItemAction.js#L5

Thanks @adamdawkins

jtraub commented 8 years ago

I just got this warning.

I believe you don't want to remove children from ProprTypes. Usually people put PropTypes.node. See https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md#as-for-exceptions

tleunen commented 8 years ago

Usually I set children as an exception, but I agree we should set it as node instead. Thanks!