File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
src/components/MuiTreeView Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ const tree = [
2525<MuiTreeView
2626 defaultExpanded
2727 onLeafClick={node => alert(JSON.stringify(node))}
28+ highlightId="example-id"
2829 tree={tree}
2930/>
3031```
Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ const styles = theme => ({
6363 maxWidth : '75vw' ,
6464 } ,
6565 expandIcon : { } ,
66+ highlightItem : {
67+ backgroundColor : 'rgb(138, 138, 138)' ,
68+ } ,
6669} ) ;
6770
6871/**
@@ -82,6 +85,8 @@ class MuiTreeView extends Component {
8285 expansionPanelDetailsProps : object ,
8386 /** Properties applied to the ListItem element. */
8487 listItemProps : object ,
88+ /** Id of a leaf which will be highlighted by adding the class */
89+ highlightId : oneOfType [ ( string , number ) ] ,
8590 } ;
8691
8792 static defaultProps = {
@@ -117,6 +122,7 @@ class MuiTreeView extends Component {
117122 expansionPanelSummaryProps,
118123 expansionPanelDetailsProps,
119124 listItemProps,
125+ highlightId,
120126 ...props
121127 } = this . props ;
122128 const value = this . getNodeValue ( node ) ;
@@ -140,6 +146,7 @@ class MuiTreeView extends Component {
140146 value = { value }
141147 onClick = { ( ) => this . handleLeafClick ( { value, parent, id } ) }
142148 button
149+ classes = { highlightId === id ? { root : classes . highlightItem } : { } }
143150 { ...listItemProps } >
144151 < div className = { classes . text } > { value } </ div >
145152 </ ListItem >
You can’t perform that action at this time.
0 commit comments