From 10baeb65a5049e8a1aba7bc6fb9bdc9874a536a4 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 | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 7314a37ced0dd..0bc312b14240a 100644 --- a/src/ui/public/vis/editors/default/agg_params.js +++ b/src/ui/public/vis/editors/default/agg_params.js @@ -45,6 +45,11 @@ uiModules $scope.aggTypeOptions = aggTypeFilters .filter(aggTypes.byType[$scope.groupName], $scope.indexPattern, $scope.agg); + // If current agg type is not part of allowed agg types, set to first element of allowed agg types + if(!$scope.aggTypeOptions.includes($scope.agg.type)) { + $scope.agg.type = $scope.aggTypeOptions[0]; + } + $scope.advancedToggled = false; // We set up this watch prior to adding the controls below, because when the controls are added,