From a1815296306ca85d52c9165f1efec350ffe00d7b Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Wed, 4 Mar 2020 08:24:33 +0100 Subject: [PATCH] make remove filter work (#58871) (#59217) --- .../vis_type_vega/public/vega_view/vega_base_view.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/legacy/core_plugins/vis_type_vega/public/vega_view/vega_base_view.js b/src/legacy/core_plugins/vis_type_vega/public/vega_view/vega_base_view.js index a6c17547d058e..76a2e672e0bd0 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/vega_view/vega_base_view.js +++ b/src/legacy/core_plugins/vis_type_vega/public/vega_view/vega_base_view.js @@ -279,10 +279,17 @@ export class VegaBaseView { */ async removeFilterHandler(query, index) { const indexId = await this._findIndex(index); - const filter = esFilters.buildQueryFilter(query, indexId); + const filterToRemove = esFilters.buildQueryFilter(query, indexId); + + const currentFilters = this._filterManager.getFilters(); + const existingFilter = currentFilters.find(filter => + esFilters.compareFilters(filter, filterToRemove) + ); + + if (!existingFilter) return; try { - this._filterManager.removeFilter(filter); + this._filterManager.removeFilter(existingFilter); } catch (err) { this.onError(err); }