From 0e60372c09cea33380df01dc144a28f5a6cd008e Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 16 Feb 2021 16:05:02 +0100 Subject: [PATCH] QueryEditors: Fixes issue that happens after moving queries then editing would update other queries (#31193) (#31244) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 0c3c17592e2cf65ef1b1eb4e54834607a7579bbe) Co-authored-by: Torkel Ödegaard --- public/app/features/query/components/QueryEditorRow.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index 56ffad62322..70606c79aef 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -75,7 +75,7 @@ export class QueryEditorRow extends PureComponent { } getAngularQueryComponentScope(): AngularQueryComponentScope { - const { query, onChange, onRunQuery, queries } = this.props; + const { query, queries } = this.props; const { datasource } = this.state; const panel = new PanelModel({ targets: queries }); const dashboard = {} as DashboardModel; @@ -87,8 +87,10 @@ export class QueryEditorRow extends PureComponent { dashboard: dashboard, refresh: () => { // Old angular editors modify the query model and just call refresh - onChange(query); - onRunQuery(); + // Important that this use this.props here so that as this fuction is only created on mount and it's + // important not to capture old prop functions in this closure + this.props.onChange(query); + this.props.onRunQuery(); }, render: () => () => console.log('legacy render function called, it does nothing'), events: new EventBusSrv(),