diff --git a/public/app/plugins/datasource/tempo/QueryEditor/NativeSearch.tsx b/public/app/plugins/datasource/tempo/QueryEditor/NativeSearch.tsx index de519bb8782..a1bf8205ab9 100644 --- a/public/app/plugins/datasource/tempo/QueryEditor/NativeSearch.tsx +++ b/public/app/plugins/datasource/tempo/QueryEditor/NativeSearch.tsx @@ -146,20 +146,6 @@ const NativeSearch = ({ datasource, query, onChange, onBlur, onRunQuery }: Props } }; - const onSpanNameChange = (v: SelectableValue) => { - // If the 'x' icon is clicked to clear the selected span name, remove spanName from the query object. - if (!v) { - delete query.spanName; - return; - } - if (spanOptions?.find((obj) => obj.value === v.value)) { - onChange({ - ...query, - spanName: v.value, - }); - } - }; - const handleOnChange = useCallback( (value) => { onChange({ @@ -184,11 +170,11 @@ const NativeSearch = ({ datasource, query, onChange, onBlur, onRunQuery }: Props loadOptions('serviceName'); }} isLoading={isLoading.serviceName} - value={serviceOptions?.find((v) => v?.value === query.serviceName) || undefined} + value={serviceOptions?.find((v) => v?.value === query.serviceName) || query.serviceName} onChange={(v) => { onChange({ ...query, - serviceName: v?.value || undefined, + serviceName: v?.value, }); }} placeholder="Select a service" @@ -208,7 +194,13 @@ const NativeSearch = ({ datasource, query, onChange, onBlur, onRunQuery }: Props loadOptions('spanName'); }} isLoading={isLoading.spanName} - onChange={onSpanNameChange} + value={spanOptions?.find((v) => v?.value === query.spanName) || query.spanName} + onChange={(v) => { + onChange({ + ...query, + spanName: v?.value, + }); + }} placeholder="Select a span" isClearable onKeyDown={onKeyDown}