File tree 3 files changed +30
-3
lines changed
src/components/containers
3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,9 @@ class Section extends Component {
59
59
}
60
60
61
61
render ( ) {
62
- const hasVisibleChildren = this . children . some ( childIsVisible ) ;
62
+ const hasVisibleChildren =
63
+ ( this . children && this . children . some ( childIsVisible ) ) ||
64
+ Boolean ( this . subPanel ) ;
63
65
64
66
return hasVisibleChildren ? (
65
67
< div className = "section" >
Original file line number Diff line number Diff line change @@ -15,12 +15,13 @@ export default class SubPanel extends Component {
15
15
16
16
render ( ) {
17
17
const toggleClass = `subpanel__toggle ${ this . props . toggleIconClass } ` ;
18
+ const isVisible = this . props . show || this . state . isVisible ;
18
19
return (
19
20
< span >
20
21
< span >
21
22
< i className = { toggleClass } onClick = { this . toggleVisibility } />
22
23
</ span >
23
- { this . state . isVisible ? (
24
+ { isVisible ? (
24
25
< div className = "subpanel" >
25
26
< div className = "subpanel__cover" onClick = { this . toggleVisibility } />
26
27
< div > { this . props . children } </ div >
@@ -33,6 +34,7 @@ export default class SubPanel extends Component {
33
34
34
35
SubPanel . propTypes = {
35
36
toggleIconClass : PropTypes . string . isRequired ,
37
+ show : PropTypes . bool ,
36
38
} ;
37
39
38
40
SubPanel . defaultProps = {
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import Section from '../Section' ;
3
+ import SubPanel from '../SubPanel' ;
3
4
import { Flaglist , Info , Numeric } from '../../fields' ;
4
5
import { TestEditor , fixtures , plotly } from '../../../lib/test-utils' ;
5
6
import { connectTraceToPlot } from '../../../lib' ;
@@ -47,7 +48,7 @@ describe('Section', () => {
47
48
) . toBe ( false ) ;
48
49
} ) ;
49
50
50
- fit ( 'is visible if it contains any non attr children' , ( ) => {
51
+ it ( 'is visible if it contains any non attr children' , ( ) => {
51
52
const wrapper = mount (
52
53
< TestEditor
53
54
plotly = { plotly }
@@ -89,4 +90,26 @@ describe('Section', () => {
89
90
expect ( wrapper . find ( Flaglist ) . exists ( ) ) . toBe ( false ) ;
90
91
expect ( wrapper . find ( Numeric ) . exists ( ) ) . toBe ( false ) ;
91
92
} ) ;
93
+
94
+ it ( 'will render first subPanel even with no visible attrs' , ( ) => {
95
+ const wrapper = mount (
96
+ < TestEditor
97
+ plotly = { plotly }
98
+ onUpdate = { jest . fn ( ) }
99
+ { ...fixtures . scatter ( { deref : true } ) }
100
+ >
101
+ < Section name = "test-section" >
102
+ < SubPanel show >
103
+ < Info > INFO</ Info >
104
+ </ SubPanel >
105
+ < SubPanel show >
106
+ < Info > MISINFORMATION</ Info >
107
+ </ SubPanel >
108
+ </ Section >
109
+ </ TestEditor >
110
+ ) . find ( '[name="test-section"]' ) ;
111
+
112
+ expect ( wrapper . find ( Info ) . length ) . toBe ( 1 ) ;
113
+ expect ( wrapper . find ( Info ) . text ( ) ) . toBe ( 'INFO' ) ;
114
+ } ) ;
92
115
} ) ;
You can’t perform that action at this time.
0 commit comments