From 360d2a2fbaa405ba0d43a365f370cc72f48edf74 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Tue, 3 Jul 2018 08:27:40 -0700 Subject: [PATCH] Check if default agg type is part of filtered list and if not, change to first agg type in list --- src/ui/public/vis/editors/default/agg.html | 2 +- src/ui/public/vis/editors/default/agg_params.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ui/public/vis/editors/default/agg.html b/src/ui/public/vis/editors/default/agg.html index c8ccdeff89b16..aa37aaa97130b 100644 --- a/src/ui/public/vis/editors/default/agg.html +++ b/src/ui/public/vis/editors/default/agg.html @@ -24,7 +24,7 @@ - + {{ aggForm.describeErrors() }} diff --git a/src/ui/public/vis/editors/default/agg_params.js b/src/ui/public/vis/editors/default/agg_params.js index cf4d7b1f7d499..4c4e5c3139f9c 100644 --- a/src/ui/public/vis/editors/default/agg_params.js +++ b/src/ui/public/vis/editors/default/agg_params.js @@ -44,7 +44,12 @@ uiModules const aggTypeSubscription = aggTypeFilters .filter$(aggTypes.byType[$scope.groupName], $scope.indexPattern, $scope.agg) - .subscribe(aggTypes => $scope.aggTypeOptions = aggTypes); + .subscribe(aggTypes => { + if(!aggTypes.includes($scope.agg.type) && aggTypes && aggTypes.length) { + $scope.agg.type = aggTypes[0]; + } + $scope.aggTypeOptions = aggTypes; + }); $scope.$on('$destroy', () => { aggTypeSubscription.unsubscribe();