diff --git a/src/sql/base/browser/ui/table/plugins/cellSelectionModel.plugin.ts b/src/sql/base/browser/ui/table/plugins/cellSelectionModel.plugin.ts index f22a479a38..c3a6384a57 100644 --- a/src/sql/base/browser/ui/table/plugins/cellSelectionModel.plugin.ts +++ b/src/sql/base/browser/ui/table/plugins/cellSelectionModel.plugin.ts @@ -127,7 +127,7 @@ export class CellSelectionModel implements Slick.SelectionModel implements Slick.Plugin { private handleHeaderClick(e: MouseEvent, args: Slick.OnHeaderClickEventArgs): void { if (args.column.id === 'rowNumber') { - this.grid.setActiveCell(0, 1); + this.grid.setActiveCell(this.grid.getViewport()?.top ?? 0, 1); let selectionModel = this.grid.getSelectionModel(); if (selectionModel) { selectionModel.setSelectedRanges([new Slick.Range(0, 0, this.grid.getDataLength() - 1, this.grid.getColumns().length - 1)]); diff --git a/src/sql/workbench/contrib/query/browser/gridPanel.ts b/src/sql/workbench/contrib/query/browser/gridPanel.ts index 26a8fe52a6..b131c71cfa 100644 --- a/src/sql/workbench/contrib/query/browser/gridPanel.ts +++ b/src/sql/workbench/contrib/query/browser/gridPanel.ts @@ -358,7 +358,6 @@ export abstract class GridTableBase extends Disposable implements IView { private _state: GridTableState; - private scrolled = false; private visible = false; private rowHeight: number; @@ -450,8 +449,6 @@ export abstract class GridTableBase extends Disposable implements IView { ); this.dataProvider.dataRows = collection; this.table.updateRowCount(); - // when we are removed slickgrid acts badly so we need to account for that - this.scrolled = false; } // actionsOrientation controls the orientation (horizontal or vertical) of the actionBar @@ -520,8 +517,6 @@ export abstract class GridTableBase extends Disposable implements IView { this._register(this.dataProvider.onFilterStateChange(() => { this.layout(); })); this._register(this.table.onContextMenu(this.contextMenu, this)); this._register(this.table.onClick(this.onTableClick, this)); - //This listener is used for correcting auto-scroling when clicking on the header for reszing. - this._register(this.table.onHeaderClick(this.onHeaderClick, this)); this._register(this.dataProvider.onFilterStateChange(() => { const columns = this.table.columns as FilterableColumn[]; this.state.columnFilters = columns.filter((column) => column.filterValues?.length > 0).map(column => { @@ -582,10 +577,6 @@ export abstract class GridTableBase extends Disposable implements IView { // so ignore those events return; } - if (!this.scrolled && (this.state.scrollPositionY || this.state.scrollPositionX) && isInDOM(this.container)) { - this.scrolled = true; - this.restoreScrollState(); - } if (this.state && isInDOM(this.container)) { this.state.scrollPositionY = data.scrollTop; this.state.scrollPositionX = data.scrollLeft; @@ -664,11 +655,6 @@ export abstract class GridTableBase extends Disposable implements IView { this._state = val; } - private onHeaderClick(event: ITableMouseEvent) { - //header clicks must be accounted for as they force the table to scroll to the top; - this.scrolled = false; - } - private async getRowData(start: number, length: number): Promise { let subset; if (this.dataProvider.isDataInMemory) {