Customer ListItem of Selectable List doesn't work in material-ui
Asked Answered
M

1

6

I used the Selectable List, but if i wrote a custome listitem, the List isn't selectable. If I used listitem directly, the list is selectable.

var DataCenterRow = React.createClass({
    render: function () {
        return (
            < ListItem primaryText = {this.props.datacenter.name}
                rightIconButton= {rightIconMenu}
                value={this.props.index} onTouchTap= {this.selectItem}/>
        );
    }
});

module.exports = DataCenterRow
Mcmann answered 18/2, 2016 at 7:24 Comment(2)
Please share a complete example, no one will be able to help otherwise. Consider reproducing the issue via jsfiddle.net or something similar. Please share which version of Material UI and ReactJS you're using.Eczema
Can you show your full code? You will have to make the <List /> component selectable using makeSelectable()Phil
P
0

If you look at the source code of makeSelectable, there is a check for muiName === 'ListItem', so make sure that your customized ListItem have type equals 'ListItem'.

ES6:
static muiName = 'ListItem';

ES5:
DataCenterRow.muiName = 'ListItem';

Don't forget to render DataCenterRow with the style got from outside (because makeSelectable will pass through selectedItemStyle to selected item)

Poling answered 27/4, 2017 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.