Skip to content

Commit aba28d9

Browse files
Refactor Packages Pane to use PositronList component (#13556)
This PR refactors the packages pane to use the new PositronList. We want to do this for a variety of reasons, but it also fixes known scroll issues on web. See: #12964 ### Release Notes #### New Features - N/A #### Bug Fixes - Fix scrolling issues in the Packages pane on web ### Validation Steps The behavior of the pane should be pretty consistent with its previous behavior. A couple of areas to note: * Selection * Focus * Right Click * Scrolling behavior * Keyboard support @:packages-pane --------- Co-authored-by: Brian Lambert <brianlambert@gmail.com>
1 parent 20b5c89 commit aba28d9

3 files changed

Lines changed: 215 additions & 191 deletions

File tree

src/vs/workbench/browser/positronList/classes/positronListInstance.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,29 @@ export class PositronListInstance<TItem, TSection = never> extends DataGridInsta
359359
);
360360
}
361361

362+
/**
363+
* Overrides the base class's row-selection so the cursor (focus) follows. The base
364+
* implementation only sets the row-selection state, leaving the cursor wherever it was —
365+
* fine for a grid where the cursor and selection are independent, wrong for a list where
366+
* the focused row should be the selected row. Selecting a section row is a no-op since
367+
* sections aren't selectable.
368+
*
369+
* The cursor and selection both update through this single entry point, so callers that
370+
* select programmatically (e.g. from an item's own click handler that stops propagation
371+
* before the data grid sees the event) get the focus indicator for free.
372+
*/
373+
override selectRow(rowIndex: number): void {
374+
const entry = this._entries[rowIndex];
375+
if (entry === undefined || entry.kind !== 'item') {
376+
return;
377+
}
378+
379+
super.selectRow(rowIndex);
380+
// List rows are single-column, so the cursor column is always 0.
381+
this.setCursorPosition(0, rowIndex);
382+
}
383+
384+
362385
/**
363386
* Fires onDidActivate for the currently focused item. PositronList wraps this with its
364387
* onActivate prop. We guard against the cursor being on a section or out-of-range row;

src/vs/workbench/contrib/positronPackages/browser/components/listPackages.css

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,21 @@
77
top: 0px;
88
}
99

10+
.positron-packages-list {
11+
height: 100%;
12+
min-height: 0;
13+
display: flex;
14+
flex-direction: column;
15+
}
16+
1017
.packages-filter-container {
18+
flex: 0 0 auto;
1119
padding: 4px 8px;
1220
}
1321

1422
.packages-list-container {
15-
height: 100%;
23+
flex: 1 1 auto;
24+
min-height: 0;
1625
position: relative;
1726
left: 0.5px;
1827
}
@@ -35,7 +44,7 @@
3544
}
3645

3746
.packages-list-item {
38-
margin-top: 5px;
47+
height: 100%;
3948
padding-left: 8px;
4049
padding-right: 8px;
4150
display: flex;
@@ -97,23 +106,9 @@
97106
font-size: 0.9em;
98107
}
99108

100-
.packages-list-item:hover {
101-
background: var(--vscode-list-hoverBackground);
102-
}
103-
104-
.packages-list-item.selected {
105-
color: var(--vscode-list-inactiveSelectionForeground);
106-
background: var(--vscode-list-inactiveSelectionBackground);
107-
outline: 1px;
108-
outline-offset: -1px;
109-
}
110-
111-
.positron-packages-list.focused .packages-list-item.selected {
112-
color: var(--vscode-list-activeSelectionForeground);
113-
background: var(--vscode-list-activeSelectionBackground);
114-
}
115-
116-
.packages-empty-message {
117-
padding: 5px 9px 5px 20px;
109+
.positron-packages-list .positron-list-empty {
110+
padding: 5px 8px;
118111
cursor: default;
112+
justify-content: flex-start;
113+
align-items: flex-start;
119114
}

0 commit comments

Comments
 (0)