1
+ import Info from '../fields/Info' ;
1
2
import MenuPanel from './MenuPanel' ;
2
3
import React , { Component , cloneElement } from 'react' ;
3
4
import PropTypes from 'prop-types' ;
4
5
import unpackPlotProps from '../../lib/unpackPlotProps' ;
5
6
import { containerConnectedContextTypes } from '../../lib/connectToContainer' ;
6
7
7
8
function childIsVisible ( child ) {
8
- return Boolean ( ( child . props . plotProps || { } ) . isVisible ) ;
9
+ const attrVisible = Boolean ( ( child . props . plotProps || { } ) . isVisible ) ;
10
+ const sectionVisible = Boolean ( child . props [ 'data-section-child-visible' ] ) ;
11
+ return attrVisible || sectionVisible ;
9
12
}
10
13
11
14
export default class Section extends Component {
@@ -47,6 +50,7 @@ export default class Section extends Component {
47
50
48
51
const isAttr = Boolean ( child . props . attr ) ;
49
52
let plotProps ;
53
+ let newProps = { } ;
50
54
if ( child . plotProps ) {
51
55
plotProps = child . plotProps ;
52
56
} else if ( isAttr ) {
@@ -58,15 +62,19 @@ export default class Section extends Component {
58
62
} else {
59
63
plotProps = unpackPlotProps ( child . props , context ) ;
60
64
}
65
+
66
+ // assign plotProps as a prop of children. If they are connectedToContainer
67
+ // it will see plotProps and skip recomputing them.
68
+ newProps = { plotProps, key : i } ;
69
+ } else if ( child . type === Info ) {
70
+ // Info panels do not change section visibility.
71
+ newProps = { key : i , 'data-section-child-visible' : false } ;
61
72
} else {
62
- plotProps = { isVisible : true } ;
73
+ // custom UI currently forces section visibility.
74
+ newProps = { key : i , 'data-section-child-visible' : true } ;
63
75
}
64
76
65
- // assign plotProps as a prop of children. If they are connectedToContainer
66
- // it will see plotProps and skip recomputing them.
67
- const childProps = Object . assign ( { plotProps} , child . props ) ;
68
-
69
- childProps . key = i ;
77
+ const childProps = Object . assign ( newProps , child . props ) ;
70
78
attrChildren . push ( cloneElement ( child , childProps ) ) ;
71
79
}
72
80
0 commit comments