mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TempoQueryEDitor: Respect onRunQuery updates (#69362)
make tempo query editor respect onRunQuery changes
This commit is contained in:
parent
9968a7324d
commit
aa6f16878f
@ -28,6 +28,10 @@ export function TraceQLEditor(props: Props) {
|
|||||||
const setupAutocompleteFn = useAutocomplete(props.datasource);
|
const setupAutocompleteFn = useAutocomplete(props.datasource);
|
||||||
const theme = useTheme2();
|
const theme = useTheme2();
|
||||||
const styles = getStyles(theme, placeholder);
|
const styles = getStyles(theme, placeholder);
|
||||||
|
// work around the problem that `onEditorDidMount` is called once
|
||||||
|
// and wouldn't get new version of onRunQuery
|
||||||
|
const onRunQueryRef = useRef(onRunQuery);
|
||||||
|
onRunQueryRef.current = onRunQuery;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
@ -56,7 +60,7 @@ export function TraceQLEditor(props: Props) {
|
|||||||
onEditorDidMount={(editor, monaco) => {
|
onEditorDidMount={(editor, monaco) => {
|
||||||
if (!props.readOnly) {
|
if (!props.readOnly) {
|
||||||
setupAutocompleteFn(editor, monaco, setupRegisterInteractionCommand(editor));
|
setupAutocompleteFn(editor, monaco, setupRegisterInteractionCommand(editor));
|
||||||
setupActions(editor, monaco, onRunQuery);
|
setupActions(editor, monaco, () => onRunQueryRef.current());
|
||||||
setupPlaceholder(editor, monaco, styles);
|
setupPlaceholder(editor, monaco, styles);
|
||||||
}
|
}
|
||||||
setupAutoSize(editor);
|
setupAutoSize(editor);
|
||||||
|
Loading…
Reference in New Issue
Block a user