From eaffa2c21bb6994b39eb476e68fb06214ddce8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 1 Feb 2023 17:23:59 +0100 Subject: [PATCH] [v9.0.x] QueryEditorRow: Fixes issue loading query editor when data source variable selected (#62657) --- .../app/features/query/components/QueryEditorRow.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index 2c730f93d1a..dcfbdad432c 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -57,8 +57,10 @@ interface Props { } interface State { + /** DatasourceUid or ds variable expression used to resolve current datasource */ loadedDataSourceIdentifier?: string | null; datasource: DataSourceApi | null; + datasourceUid?: string | null; hasTextEditMode: boolean; data?: PanelData; isOpen?: boolean; @@ -222,17 +224,17 @@ export class QueryEditorRow extends PureComponent { + isWaitingForDatasourceToLoad(): boolean { // if we not yet have loaded the datasource in state the // ds in props and the ds in state will have different values. - return this.props.dataSource.uid !== this.state.datasource?.uid; - }; + return this.props.dataSource.uid !== this.state.loadedDataSourceIdentifier; + } renderPluginEditor = () => { const { query, onChange, queries, onRunQuery, app = CoreApp.PanelEditor, history } = this.props; const { datasource, data } = this.state; - if (this.waitingForDatasourceToLoad()) { + if (this.isWaitingForDatasourceToLoad()) { return null; }