Fix #910
parent
173cff00d8
commit
25bba26244
|
@ -4,6 +4,12 @@ import { themr } from 'react-css-themr';
|
|||
import { LIST } from '../identifiers.js';
|
||||
import InjectListItem from './ListItem.js';
|
||||
|
||||
const mergeProp = (propName, child, parent) => (
|
||||
child[propName] !== undefined
|
||||
? child[propName]
|
||||
: parent[propName]
|
||||
);
|
||||
|
||||
const factory = (ListItem) => {
|
||||
class List extends Component {
|
||||
static propTypes = {
|
||||
|
@ -25,10 +31,9 @@ const factory = (ListItem) => {
|
|||
renderItems () {
|
||||
return React.Children.map(this.props.children, (item) => {
|
||||
if (item.type === ListItem) {
|
||||
return React.cloneElement(item, {
|
||||
ripple: this.props.ripple,
|
||||
selectable: this.props.selectable
|
||||
});
|
||||
const selectable = mergeProp('selectable', item.props, this.props);
|
||||
const ripple = mergeProp('ripple', item.props, this.props);
|
||||
return React.cloneElement(item, { selectable, ripple });
|
||||
} else {
|
||||
return React.cloneElement(item);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class ListTest extends React.Component {
|
|||
<List selectable ripple>
|
||||
<ListSubHeader caption='Contacts' />
|
||||
<ListItem caption='Inbox' leftIcon='inbox' />
|
||||
<ListItem caption='Outbox' leftIcon='send' />
|
||||
<ListItem caption='Outbox' selectable={false} ripple={false} leftIcon='send' />
|
||||
<ListItem caption='Trash' leftIcon='delete' />
|
||||
<ListItem caption='Spam' leftIcon='report' />
|
||||
</List>
|
||||
|
|
Loading…
Reference in New Issue