Commit 9b5890cc by kay delaney Committed by Torkel Ödegaard

QueryEditors: Fixes flakey text edit mode toggle (#18335)

Closes #18037
parent 5f4b5dfe
...@@ -83,7 +83,7 @@ export class QueryEditorRow extends PureComponent<Props, State> { ...@@ -83,7 +83,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
this.setState({ this.setState({
datasource, datasource,
loadedDataSourceValue: this.props.dataSourceValue, loadedDataSourceValue: this.props.dataSourceValue,
hasTextEditMode: false, hasTextEditMode: _.has(datasource, 'components.QueryCtrl.prototype.toggleEditorMode'),
}); });
} }
...@@ -122,14 +122,8 @@ export class QueryEditorRow extends PureComponent<Props, State> { ...@@ -122,14 +122,8 @@ export class QueryEditorRow extends PureComponent<Props, State> {
const loader = getAngularLoader(); const loader = getAngularLoader();
const template = '<plugin-component type="query-ctrl" />'; const template = '<plugin-component type="query-ctrl" />';
const scopeProps = { ctrl: this.getAngularQueryComponentScope() }; const scopeProps = { ctrl: this.getAngularQueryComponentScope() };
this.angularQueryEditor = loader.load(this.element, scopeProps, template); this.angularQueryEditor = loader.load(this.element, scopeProps, template);
this.angularScope = scopeProps.ctrl; this.angularScope = scopeProps.ctrl;
// give angular time to compile
setTimeout(() => {
this.setState({ hasTextEditMode: !!this.angularScope.toggleEditorMode });
}, 100);
} }
onToggleCollapse = () => { onToggleCollapse = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment