File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ class CheckboxTree extends React.Component {
7272 showNodeIcon : true ,
7373 showNodeTitle : false ,
7474 onCheck : ( ) => { } ,
75- onClick : ( ) => { } ,
75+ onClick : null ,
7676 onExpand : ( ) => { } ,
7777 } ;
7878
@@ -113,7 +113,6 @@ class CheckboxTree extends React.Component {
113113 if ( id !== null ) {
114114 newState = { ...newState , id } ;
115115 }
116-
117116 model . deserializeLists ( {
118117 checked : newProps . checked ,
119118 expanded : newProps . expanded ,
@@ -199,6 +198,7 @@ class CheckboxTree extends React.Component {
199198 icons,
200199 lang,
201200 noCascade,
201+ onClick,
202202 onlyLeafCheckboxes,
203203 optimisticToggle,
204204 showNodeTitle,
@@ -247,7 +247,7 @@ class CheckboxTree extends React.Component {
247247 treeId = { id }
248248 value = { node . value }
249249 onCheck = { this . onCheck }
250- onClick = { this . onNodeClick }
250+ onClick = { onClick && this . onNodeClick }
251251 onExpand = { this . onExpand }
252252 >
253253 { children }
Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ class TreeNode extends React.Component {
176176
177177 renderBareLabel ( children ) {
178178 const { onClick, title } = this . props ;
179- const clickable = onClick . toString ( ) !== TreeNode . defaultProps . onClick . toString ( ) ;
179+ const clickable = onClick !== null ;
180180
181181 return (
182182 < span className = "rct-bare-label" title = { title } >
@@ -204,7 +204,7 @@ class TreeNode extends React.Component {
204204 value,
205205 onClick,
206206 } = this . props ;
207- const clickable = onClick . toString ( ) !== TreeNode . defaultProps . onClick . toString ( ) ;
207+ const clickable = onClick !== null ;
208208 const inputId = `${ treeId } -${ String ( value ) . split ( ' ' ) . join ( '_' ) } ` ;
209209
210210 const render = [ (
Original file line number Diff line number Diff line change @@ -438,6 +438,30 @@ describe('<TreeNode />', () => {
438438 } ) ;
439439
440440 describe ( 'onClick' , ( ) => {
441+ it ( 'should render the label inside of the DOM label when null' , ( ) => {
442+ const wrapper = shallow (
443+ < TreeNode
444+ { ...baseProps }
445+ value = "jupiter"
446+ onClick = { null }
447+ /> ,
448+ ) ;
449+
450+ assert . isTrue ( wrapper . find ( 'label .rct-title' ) . exists ( ) ) ;
451+ } ) ;
452+
453+ it ( 'should render the label outside of the DOM label when NOT null' , ( ) => {
454+ const wrapper = shallow (
455+ < TreeNode
456+ { ...baseProps }
457+ value = "jupiter"
458+ onClick = { ( ) => { } }
459+ /> ,
460+ ) ;
461+
462+ assert . isFalse ( wrapper . find ( 'label .rct-title' ) . exists ( ) ) ;
463+ } ) ;
464+
441465 it ( 'should pass the current node\'s value' , ( ) => {
442466 let actual = { } ;
443467
You can’t perform that action at this time.
0 commit comments