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,