Skip to content

Commit 988d342

Browse files
committed
Remove top level child if, add it to the two individual conditions
1 parent efce3ab commit 988d342

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/components/containers/Fold.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,34 @@ class Fold extends Component {
2626
this.foldVisible = false;
2727

2828
React.Children.forEach(nextProps.children, child => {
29-
if (child) {
30-
if (child.props.attr) {
31-
let plotProps;
32-
if (child.type.supplyPlotProps) {
33-
plotProps = child.type.supplyPlotProps(child.props, nextContext);
34-
if (child.type.modifyPlotProps) {
35-
child.type.modifyPlotProps(child.props, nextContext, plotProps);
36-
}
37-
} else {
38-
plotProps = unpackPlotProps(child.props, nextContext);
39-
}
40-
41-
if (plotProps.isVisible) {
42-
this.foldVisible = true;
43-
return;
29+
if (child && child.props.attr) {
30+
let plotProps;
31+
if (child.type.supplyPlotProps) {
32+
plotProps = child.type.supplyPlotProps(child.props, nextContext);
33+
if (child.type.modifyPlotProps) {
34+
child.type.modifyPlotProps(child.props, nextContext, plotProps);
4435
}
36+
} else {
37+
plotProps = unpackPlotProps(child.props, nextContext);
4538
}
4639

47-
// allow custom components in folds to automatically show up,
48-
// except for Folds of Folds, which should keep their visibility rules
49-
if (
50-
!child.type.plotly_editor_traits ||
51-
(child.type.plotly_editor_traits &&
52-
!child.type.plotly_editor_traits.foldable)
53-
) {
40+
if (plotProps.isVisible) {
5441
this.foldVisible = true;
5542
return;
5643
}
5744
}
45+
46+
// allow custom components in folds to automatically show up,
47+
// except for Folds of Folds, which should keep their visibility rules
48+
if (
49+
child &&
50+
(!child.type.plotly_editor_traits ||
51+
(child.type.plotly_editor_traits &&
52+
!child.type.plotly_editor_traits.foldable))
53+
) {
54+
this.foldVisible = true;
55+
return;
56+
}
5857
});
5958
}
6059

0 commit comments

Comments
 (0)