@@ -52,6 +52,9 @@ const styles = theme => ({
5252 maxWidth : '75vw' ,
5353 } ,
5454 expandIcon : { } ,
55+ highlightItem : {
56+ backgroundColor : 'rgb(220, 227, 239)' ,
57+ } ,
5558} ) ;
5659
5760/**
@@ -71,6 +74,8 @@ class MuiTreeView extends Component {
7174 expansionPanelDetailsProps : object ,
7275 /** Properties applied to the ListItem element. */
7376 listItemProps : object ,
77+ /** Value path for some leaf to highlight */
78+ highlightItem : arrayOf ( string ) ,
7479 } ;
7580
7681 static defaultProps = {
@@ -79,6 +84,7 @@ class MuiTreeView extends Component {
7984 expansionPanelSummaryProps : null ,
8085 expansionPanelDetailsProps : null ,
8186 listItemProps : null ,
87+ highlightItem : null ,
8288 } ;
8389
8490 createFilteredTree = memoize (
@@ -106,6 +112,7 @@ class MuiTreeView extends Component {
106112 expansionPanelSummaryProps,
107113 expansionPanelDetailsProps,
108114 listItemProps,
115+ highlightItem,
109116 ...props
110117 } = this . props ;
111118 const value = this . getNodeValue ( node ) ;
@@ -120,6 +127,14 @@ class MuiTreeView extends Component {
120127 }
121128
122129 if ( isLeaf ) {
130+ let isHighlighted = false ;
131+
132+ if ( highlightItem ) {
133+ if ( JSON . stringify ( currentPath ) === JSON . stringify ( highlightItem ) ) {
134+ isHighlighted = true ;
135+ }
136+ }
137+
123138 return (
124139 < ListItem
125140 disableGutters
@@ -129,6 +144,7 @@ class MuiTreeView extends Component {
129144 value = { value }
130145 onClick = { ( ) => this . handleLeafClick ( value , parent , currentPath ) }
131146 button
147+ classes = { isHighlighted ? { root : classes . highlightItem } : { } }
132148 { ...listItemProps } >
133149 < div className = { classes . text } > { value } </ div >
134150 </ ListItem >
0 commit comments