[v9.3.x] Graphite: bug fix, strip white space from queries before comparing them (#60349)

Graphite: bug fix, strip white space from queries before comparing them (#60133)

strip white space from queries before comparing them

(cherry picked from commit d5d07894b1)

Co-authored-by: Brendan O'Handley <brendan.ohandley@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-12-14 11:53:33 -05:00
committed by GitHub
co-authored by Brendan O'Handley
parent 714bf79b93
commit 661169720a
@@ -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();
}
}