import React, { FormEvent, ReactElement, useCallback } from 'react'; import { selectors } from '@grafana/e2e-selectors'; import { VerticalGroup } from '@grafana/ui'; import { VariableSectionHeader } from '../editor/VariableSectionHeader'; import { VariableTextField } from '../editor/VariableTextField'; import { VariableEditorProps } from '../editor/types'; import { TextBoxVariableModel } from '../types'; export interface Props extends VariableEditorProps {} export function TextBoxVariableEditor({ onPropChange, variable: { query } }: Props): ReactElement { const updateVariable = useCallback( (event: FormEvent, updateOptions: boolean) => { event.preventDefault(); onPropChange({ propName: 'originalQuery', propValue: event.currentTarget.value, updateOptions: false }); onPropChange({ propName: 'query', propValue: event.currentTarget.value, updateOptions }); }, [onPropChange] ); const onChange = useCallback((e: FormEvent) => updateVariable(e, false), [updateVariable]); const onBlur = useCallback((e: FormEvent) => updateVariable(e, true), [updateVariable]); return ( ); }