From 787245b0585d6d14ab91224840c3ceddfbd99c42 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Thu, 3 Sep 2020 21:36:11 -0700 Subject: [PATCH] Don't propagate click when clicking on header filter (#12130) --- .../ui/table/plugins/headerFilter.plugin.ts | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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 1959ef5d44..aa4e24fb01 100644 --- a/src/sql/base/browser/ui/table/plugins/headerFilter.plugin.ts +++ b/src/sql/base/browser/ui/table/plugins/headerFilter.plugin.ts @@ -14,10 +14,16 @@ interface IExtendedColumn extends Slick.Column { filterValues?: Array; } +export interface CommandEventArgs { + grid: Slick.Grid, + column: Slick.Column, + command: string +} + export class HeaderFilter { public onFilterApplied = new Slick.Event(); - public onCommand = new Slick.Event(); + public onCommand = new Slick.Event>(); private grid!: Slick.Grid; private handler = new Slick.EventHandler(); @@ -82,10 +88,16 @@ export class HeaderFilter { .addClass('slick-header-menubutton') .data('column', column); - $el.bind('click', (e: KeyboardEvent) => this.showFilter(e)).appendTo(args.node); + $el.bind('click', (e: KeyboardEvent) => { + this.showFilter(e); + e.preventDefault(); + e.stopPropagation(); + }).appendTo(args.node); $el.bind('keydown', (e: KeyboardEvent) => { if (e.key === 'Enter' || e.keyCode === 13) { this.showFilter(e); + e.preventDefault(); + e.stopPropagation(); } }).appendTo(args.node); } @@ -377,9 +389,9 @@ export class HeaderFilter { this.hideMenu(); this.onCommand.notify({ - 'grid': this.grid, - 'column': columnDef, - 'command': command + grid: this.grid, + column: columnDef, + command: command }, e, self); e.preventDefault();