Skip to content

Commit 887b2df

Browse files
authored
Fix Vega plots disappearing (#4673)
1 parent adbb2cb commit 887b2df

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

webview/src/plots/components/App.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ describe('App', () => {
635635
expect(screen.queryByText('Images')).not.toBeInTheDocument()
636636
})
637637

638-
it('should toggle the custom plots section in state when its header is clicked', async () => {
638+
it('should hide plots when their section is collapsed (setting to null can break some Vega plots)', async () => {
639639
renderAppWithOptionalData({
640640
custom: customPlotsFixture
641641
})
@@ -664,9 +664,11 @@ describe('App', () => {
664664
}
665665
})
666666

667-
expect(
668-
screen.queryByLabelText('Vega visualization')
669-
).not.toBeInTheDocument()
667+
const hiddenPlots = await screen.findAllByLabelText('Vega visualization')
668+
for (const hiddenPlot of hiddenPlots) {
669+
expect(hiddenPlot).toBeInTheDocument()
670+
expect(hiddenPlot).not.toBeVisible()
671+
}
670672
})
671673

672674
it('should not toggle the custom plots section when its header is clicked and its title is selected', async () => {

webview/src/plots/components/PlotsContainer.tsx

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,25 +156,20 @@ export const PlotsContainer: React.FC<PlotsContainerProps> = ({
156156
)
157157
}
158158
>
159-
{open && (
160-
<div
161-
className={cx({
162-
[styles.plotsWrapper]: sectionKey !== PlotsSection.COMPARISON_TABLE,
163-
[styles.smallPlots]: nbItemsPerRowOrWidth >= 4
164-
})}
165-
style={
166-
{
167-
'--nb-per-row': nbItemsPerRowOrWidth
168-
} as DetailedHTMLProps<
169-
HTMLAttributes<HTMLDivElement>,
170-
HTMLDivElement
171-
>
172-
}
173-
data-testid="plots-wrapper"
174-
>
175-
{children}
176-
</div>
177-
)}
159+
<div
160+
className={cx({
161+
[styles.plotsWrapper]: sectionKey !== PlotsSection.COMPARISON_TABLE,
162+
[styles.smallPlots]: nbItemsPerRowOrWidth >= 4
163+
})}
164+
style={
165+
{
166+
'--nb-per-row': nbItemsPerRowOrWidth
167+
} as DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
168+
}
169+
data-testid="plots-wrapper"
170+
>
171+
{children}
172+
</div>
178173
</SectionContainer>
179174
)
180175
}

0 commit comments

Comments
 (0)