Skip to content

Commit f59dc37

Browse files
authored
Merge pull request #1283 from mito-ds/graph-undo-bug
Fix bug when opening graph editor then pressing undo
2 parents c499291 + 0a2d6b5 commit f59dc37

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

mitosheet/src/mito/Mito.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,23 @@ export const Mito = (props: MitoProps): JSX.Element => {
335335
loadPlotly()
336336
}, [])
337337

338+
/**
339+
* This useEffect handles when the user creates a graph, then presses undo.
340+
*/
341+
useEffect(() => {
342+
if (uiState.currOpenTaskpane.type === TaskpaneType.GRAPH &&
343+
analysisData.graphDataArray.length === 0) {
344+
setUIState(prevUIState => {
345+
return {
346+
...prevUIState,
347+
currOpenTaskpane: {type: TaskpaneType.NONE},
348+
selectedTabType: 'data',
349+
selectedSheetIndex: 0
350+
}
351+
})
352+
}
353+
}, [analysisData.graphDataArray.length])
354+
338355
/*
339356
When the number of sheets increases, we make sure
340357
that the last sheet is highlighted. If it decreases,

tests/streamlit_ui_tests/graph.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ test.describe('Graph Functionality', () => {
193193
await expect(mito.getByText('Facet row')).toBeInViewport();
194194
});
195195

196+
test('Pressing undo after opening graph editor closes the graph editor', async ({ page }) => {
197+
const mito = await getMitoFrameWithTestCSV(page);
198+
await openGraphEditor(mito, page);
199+
await mito.getByTitle(/Undo the most recent edit/).click();
200+
await expect(mito.locator('.tab-selected', { hasText: 'test' })).toBeVisible();
201+
await expect(mito.locator('.endo-column-header-final-text').first()).toHaveText('Column1');
202+
});
203+
196204
test('Make a histogram and change the histogram specific configurations', async ({ page }) => {
197205
const mito = await getMitoFrameWithTestCSV(page);
198206

0 commit comments

Comments
 (0)