Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Vega plots disappearing #4673

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions webview/src/plots/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ describe('App', () => {
expect(screen.queryByText('Images')).not.toBeInTheDocument()
})

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

expect(
screen.queryByLabelText('Vega visualization')
).not.toBeInTheDocument()
const hiddenPlots = await screen.findAllByLabelText('Vega visualization')
for (const hiddenPlot of hiddenPlots) {
expect(hiddenPlot).toBeInTheDocument()
expect(hiddenPlot).not.toBeVisible()
}
})

it('should not toggle the custom plots section when its header is clicked and its title is selected', async () => {
Expand Down
33 changes: 14 additions & 19 deletions webview/src/plots/components/PlotsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,20 @@ export const PlotsContainer: React.FC<PlotsContainerProps> = ({
)
}
>
{open && (
<div
className={cx({
[styles.plotsWrapper]: sectionKey !== PlotsSection.COMPARISON_TABLE,
[styles.smallPlots]: nbItemsPerRowOrWidth >= 4
})}
style={
{
'--nb-per-row': nbItemsPerRowOrWidth
} as DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>
}
data-testid="plots-wrapper"
>
{children}
</div>
)}
<div
className={cx({
[styles.plotsWrapper]: sectionKey !== PlotsSection.COMPARISON_TABLE,
[styles.smallPlots]: nbItemsPerRowOrWidth >= 4
})}
style={
{
'--nb-per-row': nbItemsPerRowOrWidth
} as DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
}
data-testid="plots-wrapper"
>
{children}
</div>
</SectionContainer>
)
}
Loading