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

strip white space from queries before comparing them
This commit is contained in:
Brendan O'Handley 2022-12-14 11:39:29 -05:00 committed by GitHub
parent 4be99c56f6
commit d5d07894b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();
}
}