TempoQueryEDitor: Respect onRunQuery updates (#69362)

make tempo query editor respect onRunQuery changes
pull/69368/head
Domas 2 years ago committed by GitHub
parent 9968a7324d
commit aa6f16878f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      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 (
<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…
Cancel
Save