Skip to content

Commit f9e5002

Browse files
Collapse summary panel on initial render if width exceeds 50% (#8854)
1 parent 23268b1 commit f9e5002

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

src/vs/workbench/browser/positronDataExplorer/components/dataExplorerPanel/components/dataExplorer.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,25 @@ export const DataExplorer = () => {
240240
// Automatic layout useEffect.
241241
useLayoutEffect(() => {
242242
// Set the initial width.
243-
setWidth(dataExplorerRef.current.offsetWidth);
243+
const initialWidth = dataExplorerRef.current.offsetWidth;
244+
setWidth(initialWidth);
244245

245246
// Set the initial columns width - use stored width or default
246247
const savedWidth = context.instance.summaryWidth;
247-
setColumnsWidth(
248-
savedWidth > 0 ?
249-
Math.max(savedWidth, MIN_COLUMN_WIDTH) :
250-
DEFAULT_SUMMARY_WIDTH
251-
);
248+
const columnsWidth = savedWidth > 0
249+
? Math.max(savedWidth, MIN_COLUMN_WIDTH)
250+
: DEFAULT_SUMMARY_WIDTH;
251+
setColumnsWidth(columnsWidth);
252+
253+
// Collapse the summary panel if it would take up more than 50%
254+
// of the width and isn't already collapsed
255+
if (columnsWidth > (initialWidth * 0.5) && !context.instance.isSummaryCollapsed) {
256+
context.instance.collapseSummary();
257+
// Set the summary panel collapsed state manually here in case the
258+
// onDidCollapseSummary event is not registered by the time this
259+
// layout effect runs
260+
setColumnsCollapsed(true);
261+
}
252262

253263
// Allocate and initialize the data explorer resize observer.
254264
const resizeObserver = new ResizeObserver(entries => {
@@ -260,7 +270,7 @@ export const DataExplorer = () => {
260270

261271
// Return the cleanup function that will disconnect the resize observer.
262272
return () => resizeObserver.disconnect();
263-
}, [context.instance.summaryWidth]);
273+
}, [context.instance]);
264274

265275
// ColumnsWidth Layout useEffect.
266276
useLayoutEffect(() => {

test/e2e/tests/data-explorer/data-explorer-python-pandas.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ test.describe('Data Explorer - Python Pandas', {
4343
await clipboard.expectClipboardTextToBe('Jai');
4444

4545
// verify sparkline hover dialog
46+
await dataExplorer.expandSummary();
4647
await dataExplorer.verifySparklineHoverDialog(['Value', 'Count']);
4748

4849
// verify null percentage hover dialog

test/e2e/tests/data-explorer/duckdb-sparklines.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test.describe('Data Explorer - DuckDB Column Summary', {
2222
await openDataFile('data-files/100x100/100x100.parquet');
2323
await hotKeys.notebookLayout();
2424

25+
await dataExplorer.expandSummary();
2526
await dataExplorer.verifyMissingPercent([
2627
{ column: 1, expected: '0%' },
2728
{ column: 2, expected: '0%' },

test/e2e/tests/data-explorer/sparklines.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ test.describe('Data Explorer - Sparklines', {
3232
await hotKeys.closePrimarySidebar();
3333
await hotKeys.closeSecondarySidebar();
3434

35+
await dataExplorer.expandSummary();
3536
await dataExplorer.verifySparklineHeights([{ column: 1, expected: ['50.0', '40.0', '30.0', '20.0', '10.0'] }]);
3637
});
3738

@@ -47,6 +48,7 @@ test.describe('Data Explorer - Sparklines', {
4748
await hotKeys.closePrimarySidebar();
4849
await hotKeys.closeSecondarySidebar();
4950

51+
await dataExplorer.expandSummary();
5052
await dataExplorer.verifySparklineHeights([{ column: 1, expected: ['50.0', '40.0', '30.0', '20.0', '10.0'] }]);
5153
});
5254
});

test/e2e/tests/editor-action-bar/editor-action-bar-data-files.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
* - Verify the Editor Action Bar functionality:
1717
*/
1818

19-
import { Application } from '../../infra';
19+
import { Application, DataExplorer } from '../../infra';
2020
import { EditorActionBar } from '../../pages/editorActionBar';
2121
import { test, expect, tags } from '../_test.setup';
2222

2323
let editorActionBar: EditorActionBar;
24+
let dataExplorer: DataExplorer;
2425

2526
const testCases = [
2627
{
@@ -56,6 +57,7 @@ test.describe('Editor Action Bar: Data Files', {
5657

5758
test.beforeAll(async function ({ app }) {
5859
editorActionBar = app.workbench.editorActionBar;
60+
dataExplorer = app.workbench.dataExplorer;
5961
});
6062

6163
test.afterEach(async function ({ runCommand }) {
@@ -79,6 +81,9 @@ test.describe('Editor Action Bar: Data Files', {
7981
await openDataExplorerViaVariablePane(app, testCase.variable, testCase.tabName);
8082
}
8183

84+
// Ensure the summary panel is visible
85+
await dataExplorer.expandSummary();
86+
8287
// Verify action bar behavior
8388
await editorActionBar.selectSummaryOn(app.web, 'Left');
8489
await editorActionBar.verifySummaryPosition('Left');

0 commit comments

Comments
 (0)