Skip to content

Commit 5a412cf

Browse files
MenuPanel does not trigger section visibility
1 parent 9ede170 commit 5a412cf

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/components/containers/Section.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ export default class Section extends Component {
7676

7777
render() {
7878
const hasVisibleChildren =
79-
(this.children && this.children.some(childIsVisible)) ||
80-
Boolean(this.menuPanel);
79+
this.children && this.children.some(childIsVisible);
8180

8281
return hasVisibleChildren ? (
8382
<div className="section">

src/components/containers/__tests__/Section-test.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,44 @@ describe('Section', () => {
8181
expect(wrapper.find(Numeric).exists()).toBe(false);
8282
});
8383

84-
it('will render first menuPanel even with no visible attrs', () => {
84+
it('will render first menuPanel', () => {
85+
const TraceSection = connectTraceToPlot(Section);
8586
const wrapper = mount(
8687
<TestEditor onUpdate={jest.fn()} {...fixtures.scatter()}>
87-
<Section name="test-section">
88+
<TraceSection name="test-section" traceIndex={0}>
89+
<Numeric attr="opacity" traceIndex={0} />
8890
<MenuPanel show>
8991
<Info>INFO</Info>
9092
</MenuPanel>
9193
<MenuPanel show>
9294
<Info>MISINFORMATION</Info>
9395
</MenuPanel>
94-
</Section>
96+
</TraceSection>
9597
</TestEditor>
9698
).find('[name="test-section"]');
9799

100+
expect(wrapper.find(MenuPanel).length).toBe(1);
98101
expect(wrapper.find(Info).length).toBe(1);
99102
expect(wrapper.find(Info).text()).toBe('INFO');
100103
});
104+
105+
it('will hides even with MenuPanel when attrs not defined', () => {
106+
const TraceSection = connectTraceToPlot(Section);
107+
const wrapper = mount(
108+
<TestEditor onUpdate={jest.fn()} {...fixtures.scatter()}>
109+
<TraceSection name="test-section" traceIndex={0}>
110+
<Numeric attr="badattr" traceIndex={0} />
111+
<MenuPanel show>
112+
<Info>INFO</Info>
113+
</MenuPanel>
114+
<MenuPanel show>
115+
<Info>MISINFORMATION</Info>
116+
</MenuPanel>
117+
</TraceSection>
118+
</TestEditor>
119+
).find('[name="test-section"]');
120+
121+
expect(wrapper.find(MenuPanel).length).toBe(0);
122+
expect(wrapper.find(Info).length).toBe(0);
123+
});
101124
});

0 commit comments

Comments
 (0)