mirror of
https://github.com/grafana/grafana.git
synced 2025-01-26 16:27:02 -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 theme = useTheme2();
|
||||
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 (
|
||||
<CodeEditor
|
||||
@ -56,7 +60,7 @@ export function TraceQLEditor(props: Props) {
|
||||
onEditorDidMount={(editor, monaco) => {
|
||||
if (!props.readOnly) {
|
||||
setupAutocompleteFn(editor, monaco, setupRegisterInteractionCommand(editor));
|
||||
setupActions(editor, monaco, onRunQuery);
|
||||
setupActions(editor, monaco, () => onRunQueryRef.current());
|
||||
setupPlaceholder(editor, monaco, styles);
|
||||
}
|
||||
setupAutoSize(editor);
|
||||
|
Loading…
Reference in New Issue
Block a user