diff --git a/public/app/plugins/datasource/graphite/state/helpers.ts b/public/app/plugins/datasource/graphite/state/helpers.ts index 8a174d7fa4a..5231991f08a 100644 --- a/public/app/plugins/datasource/graphite/state/helpers.ts +++ b/public/app/plugins/datasource/graphite/state/helpers.ts @@ -158,7 +158,7 @@ export function handleTargetChanged(state: GraphiteQueryEditorState): void { return; } - const oldTarget = state.queryModel.target.target; + let oldTarget = state.queryModel.target.target; // Interpolate from other queries: // Because of mixed data sources the list may contain queries for non-Graphite data sources. To ensure a valid query // is used for interpolation we should check required properties are passed though in theory it allows to interpolate @@ -167,7 +167,11 @@ export function handleTargetChanged(state: GraphiteQueryEditorState): void { (state.queries || []).filter((query) => 'target' in query && typeof (query as GraphiteQuery).target === 'string') ); - if (state.queryModel.target.target !== oldTarget && !state.paused) { + // remove spaces from old and new targets + const newTarget = state.queryModel.target.target.replace(/\s+/g, ''); + oldTarget = oldTarget.replace(/\s+/g, ''); + + if (newTarget !== oldTarget && !state.paused) { state.refresh(); } }