@@ -2,7 +2,9 @@ import { debounce } from 'lodash';
22import React , { FormEvent , useEffect , useState } from 'react' ;
33
44import { DEFAULT_FIELD_DISPLAY_VALUES_LIMIT , QueryEditorProps , SelectableValue } from '@grafana/data' ;
5- import { Combobox , InlineField , InlineFieldRow , Input , Select } from '@grafana/ui' ;
5+ import { InlineField , InlineFieldRow , Input , Select } from '@grafana/ui' ;
6+
7+ import { CompatibleCombobox } from '../CompatibleCombobox' ;
68
79import { VictoriaLogsDatasource } from '../../datasource' ;
810import { FilterFieldType , Options , Query , VariableQuery } from '../../types' ;
@@ -21,7 +23,7 @@ export const VariableQueryEditor = ({ onChange, query, datasource, range }: Prop
2123 const [ queryFilter , setQueryFilter ] = useState < string > ( '' ) ;
2224 const [ field , setField ] = useState < string > ( '' ) ;
2325 const [ limit , setLimit ] = useState < number > ( DEFAULT_FIELD_DISPLAY_VALUES_LIMIT ) ;
24- const [ fieldNames , setFieldNames ] = useState < SelectableValue < string > [ ] > ( [ ] ) ;
26+ const [ fieldNames , setFieldNames ] = useState < Array < { value : string ; label : string ; description ?: string } > > ( [ ] ) ;
2527 const [ isLoading , setIsLoading ] = useState < boolean > ( false ) ;
2628 const [ error , setError ] = useState < string > ( '' ) ;
2729
@@ -33,6 +35,12 @@ export const VariableQueryEditor = ({ onChange, query, datasource, range }: Prop
3335 onChange ( { refId, type : newType . value , field, query : queryFilter } ) ;
3436 } ;
3537
38+ const handleFieldChange = ( option : { value : string } ) => {
39+ const newField = String ( option . value ) ;
40+ setField ( newField ) ;
41+ onChange ( { refId, type : type ! , field : newField , query : queryFilter , limit } ) ;
42+ } ;
43+
3644 const handleBlur = ( ) => {
3745 if ( ! type ) {
3846 return ;
@@ -127,13 +135,9 @@ export const VariableQueryEditor = ({ onChange, query, datasource, range }: Prop
127135 error = { error }
128136 invalid = { ! ! error }
129137 >
130- < Combobox
138+ < CompatibleCombobox
131139 placeholder = 'Select field'
132- onChange = { ( option ) => {
133- const newField = String ( option . value ) ;
134- setField ( newField ) ;
135- onChange ( { refId, type : type ! , field : newField , query : queryFilter , limit } ) ;
136- } }
140+ onChange = { handleFieldChange }
137141 value = { field || null }
138142 options = { fieldNames }
139143 width = { 20 }
0 commit comments