diff --git a/public/app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx b/public/app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx index 06b73580b4b..b2126bbe2b7 100644 --- a/public/app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx +++ b/public/app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx @@ -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 ( { if (!props.readOnly) { setupAutocompleteFn(editor, monaco, setupRegisterInteractionCommand(editor)); - setupActions(editor, monaco, onRunQuery); + setupActions(editor, monaco, () => onRunQueryRef.current()); setupPlaceholder(editor, monaco, styles); } setupAutoSize(editor);