diff --git a/src/sql/base/browser/ui/table/plugins/headerFilter.plugin.ts b/src/sql/base/browser/ui/table/plugins/headerFilter.plugin.ts index 915de5daeb..cc249a3c8d 100644 --- a/src/sql/base/browser/ui/table/plugins/headerFilter.plugin.ts +++ b/src/sql/base/browser/ui/table/plugins/headerFilter.plugin.ts @@ -142,6 +142,15 @@ export class HeaderFilter { // the the filter button has already being added to the header return; } + + // The default sorting feature is triggered by clicking on the column header, but that is conflicting with query editor grid, + // For query editor grid when column header is clicked, the entire column will be selected. + // If the column is not defined as sortable because of the above reason, we will add the sort indicator here. + if (column.sortable !== true) { + args.node.classList.add('slick-header-sortable'); + append(args.node, $('span.slick-sort-indicator')); + } + args.node.classList.add('slick-header-with-filter'); const $el = jQuery(``) .addClass('slick-header-menubutton') @@ -478,6 +487,9 @@ export class HeaderFilter { private async handleMenuItemClick(command: HeaderFilterCommands, columnDef: Slick.Column) { this.hideMenu(); const dataView = this.grid.getData(); + if (command === 'sort-asc' || command === 'sort-desc') { + this.grid.setSortColumn(columnDef.id, command === 'sort-asc'); + } if (instanceOfIDisposableDataProvider(dataView) && (command === 'sort-asc' || command === 'sort-desc')) { await dataView.sort({ grid: this.grid, diff --git a/src/sql/workbench/contrib/query/browser/gridPanel.ts b/src/sql/workbench/contrib/query/browser/gridPanel.ts index c51f30b8ff..0b56f27bea 100644 --- a/src/sql/workbench/contrib/query/browser/gridPanel.ts +++ b/src/sql/workbench/contrib/query/browser/gridPanel.ts @@ -625,11 +625,14 @@ export abstract class GridTableBase extends Disposable implements IView { } if (this.state.sortState) { + const sortAsc = this.state.sortState.sortAsc; + const sortCol = this.columns.find((column) => column.field === this.state.sortState.field); + this.table.grid.setSortColumn(sortCol.id, sortAsc); await this.dataProvider.sort({ multiColumnSort: false, grid: this.table.grid, - sortAsc: this.state.sortState.sortAsc, - sortCol: this.columns.find((column) => column.field === this.state.sortState.field) + sortAsc: sortAsc, + sortCol: sortCol }); }