From e7930a27b571c75d1ce01e08097346c1f48abf91 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Fri, 10 May 2019 14:09:07 +0200 Subject: [PATCH] explore: add some extra time for angular query editors to update query (#16955) Now when loading a query editor which changes the default query in the constructor this will result in the actual updated query is used in explore when running the query. Without this, the query used is sort of out of sync between query editor and executed query. --- public/app/features/explore/QueryEditor.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/app/features/explore/QueryEditor.tsx b/public/app/features/explore/QueryEditor.tsx index 0d34ee5249e..30f876886c1 100644 --- a/public/app/features/explore/QueryEditor.tsx +++ b/public/app/features/explore/QueryEditor.tsx @@ -41,11 +41,15 @@ export default class QueryEditor extends PureComponent { datasource, target, refresh: () => { - this.props.onQueryChange(target); - this.props.onExecuteQuery(); + setTimeout(() => { + this.props.onQueryChange(target); + this.props.onExecuteQuery(); + }, 1); }, onQueryChange: () => { - this.props.onQueryChange(target); + setTimeout(() => { + this.props.onQueryChange(target); + }, 1); }, events: exploreEvents, panel: { datasource, targets: [target] }, @@ -54,7 +58,9 @@ export default class QueryEditor extends PureComponent { }; this.component = loader.load(this.element, scopeProps, template); - this.props.onQueryChange(target); + setTimeout(() => { + this.props.onQueryChange(target); + }, 1); } componentDidUpdate(prevProps: QueryEditorProps) {