Skip to content

Commit 5be9c12

Browse files
authored
Merge pull request #389 from plotly/folds
Custom component in Fold fix
2 parents 0880ad0 + 988d342 commit 5be9c12

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/components/containers/Fold.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Fold extends Component {
2626
this.foldVisible = false;
2727

2828
React.Children.forEach(nextProps.children, child => {
29-
if (child.props.attr) {
29+
if (child && child.props.attr) {
3030
let plotProps;
3131
if (child.type.supplyPlotProps) {
3232
plotProps = child.type.supplyPlotProps(child.props, nextContext);
@@ -42,6 +42,18 @@ class Fold extends Component {
4242
return;
4343
}
4444
}
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+
}
4557
});
4658
}
4759

0 commit comments

Comments
 (0)