@@ -85,8 +85,12 @@ class MuiTreeView extends Component {
8585 expansionPanelDetailsProps : object ,
8686 /** Properties applied to the ListItem element. */
8787 listItemProps : object ,
88- /** Id of a leaf which will be highlighted by adding the class */
89- highlightId : oneOfType [ ( string , number ) ] ,
88+ /** Id of a leaf which will be highlighted by adding the class highlightItem
89+ * or a style given by the hightlightStyle prop.
90+ */
91+ highlightId : oneOfType ( [ string , number ] ) ,
92+ /* styling of the highlighted item */
93+ highlightClass : string ,
9094 } ;
9195
9296 static defaultProps = {
@@ -95,6 +99,7 @@ class MuiTreeView extends Component {
9599 expansionPanelSummaryProps : null ,
96100 expansionPanelDetailsProps : null ,
97101 listItemProps : null ,
102+ highlightClass : null ,
98103 } ;
99104
100105 createFilteredTree = memoize (
@@ -123,11 +128,22 @@ class MuiTreeView extends Component {
123128 expansionPanelDetailsProps,
124129 listItemProps,
125130 highlightId,
131+ highlightClass,
126132 ...props
127133 } = this . props ;
128134 const value = this . getNodeValue ( node ) ;
129135 const id = this . getNodeId ( node ) ;
130136 const isLeaf = this . isLeaf ( node ) ;
137+ let additionalClasses = { } ;
138+
139+ if ( highlightId === node . id ) {
140+ if ( highlightClass ) {
141+ additionalClasses = { root : highlightClass } ;
142+ } else {
143+ additionalClasses = { root : classes . highlightItem } ;
144+ }
145+ }
146+
131147 const textIndent = isLeaf
132148 ? depth * unit + unit + ( parent ? unit : 0 )
133149 : unit * depth + unit ;
@@ -146,7 +162,7 @@ class MuiTreeView extends Component {
146162 value = { value }
147163 onClick = { ( ) => this . handleLeafClick ( { value, parent, id } ) }
148164 button
149- classes = { highlightId === id ? { root : classes . highlightItem } : { } }
165+ classes = { additionalClasses }
150166 { ...listItemProps } >
151167 < div className = { classes . text } > { value } </ div >
152168 </ ListItem >
0 commit comments