Skip to content

Commit

Permalink
explore: add some extra time for angular query editors to update query (
Browse files Browse the repository at this point in the history
grafana#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.
  • Loading branch information
marefr authored May 10, 2019
1 parent 6dbaa70 commit e7930a2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions public/app/features/explore/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
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] },
Expand All @@ -54,7 +58,9 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
};

this.component = loader.load(this.element, scopeProps, template);
this.props.onQueryChange(target);
setTimeout(() => {
this.props.onQueryChange(target);
}, 1);
}

componentDidUpdate(prevProps: QueryEditorProps) {
Expand Down

0 comments on commit e7930a2

Please sign in to comment.