diff --git a/public/app/plugins/datasource/graphite/query_ctrl.ts b/public/app/plugins/datasource/graphite/query_ctrl.ts index 6b19c69dc58..4737ec95103 100644 --- a/public/app/plugins/datasource/graphite/query_ctrl.ts +++ b/public/app/plugins/datasource/graphite/query_ctrl.ts @@ -5,6 +5,7 @@ import _ from 'lodash'; import GraphiteQuery from './graphite_query'; import { QueryCtrl } from 'app/plugins/sdk'; import appEvents from 'app/core/app_events'; +import { promiseToDigest } from 'app/core/utils/promiseToDigest'; import { auto } from 'angular'; import { TemplateSrv } from 'app/features/templating/template_srv'; import { AppEvents } from '@grafana/data'; @@ -59,7 +60,8 @@ export class GraphiteQueryCtrl extends QueryCtrl { }); const checkOtherSegmentsIndex = this.queryModel.checkOtherSegmentsIndex || 0; - this.checkOtherSegments(checkOtherSegmentsIndex, modifyLastSegment); + + promiseToDigest(this.$scope)(this.checkOtherSegments(checkOtherSegmentsIndex, modifyLastSegment)); if (this.queryModel.seriesByTagUsed) { this.fixTagSegments(); @@ -207,20 +209,24 @@ export class GraphiteQueryCtrl extends QueryCtrl { const tag = removeTagPrefix(segment.value); this.pause(); this.addSeriesByTagFunc(tag); - return; + return null; } if (segment.expandable) { - return this.checkOtherSegments(segmentIndex + 1).then(() => { - this.setSegmentFocus(segmentIndex + 1); - this.targetChanged(); - }); + return promiseToDigest(this.$scope)( + this.checkOtherSegments(segmentIndex + 1).then(() => { + this.setSegmentFocus(segmentIndex + 1); + this.targetChanged(); + }) + ); } else { this.spliceSegments(segmentIndex + 1); } this.setSegmentFocus(segmentIndex + 1); this.targetChanged(); + + return null; } spliceSegments(index: any) { diff --git a/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts b/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts index 7256cce2bb5..a6f3eaa139b 100644 --- a/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts +++ b/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts @@ -3,6 +3,12 @@ import gfunc from '../gfunc'; import { GraphiteQueryCtrl } from '../query_ctrl'; import { TemplateSrvStub } from 'test/specs/helpers'; +jest.mock('app/core/utils/promiseToDigest', () => ({ + promiseToDigest: (scope: any) => { + return (p: Promise) => p; + }, +})); + describe('GraphiteQueryCtrl', () => { const ctx = { datasource: {