diff --git a/public/app/plugins/datasource/influxdb/components/VisualInfluxQLEditor/Seg.tsx b/public/app/plugins/datasource/influxdb/components/VisualInfluxQLEditor/Seg.tsx index a77eec1b5d7..db9af3b04ab 100644 --- a/public/app/plugins/datasource/influxdb/components/VisualInfluxQLEditor/Seg.tsx +++ b/public/app/plugins/datasource/influxdb/components/VisualInfluxQLEditor/Seg.tsx @@ -1,8 +1,8 @@ -import React, { useState, useRef, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import debouncePromise from 'debounce-promise'; import { cx, css } from '@emotion/css'; import { SelectableValue } from '@grafana/data'; -import { useClickAway, useAsyncFn } from 'react-use'; +import { useAsyncFn } from 'react-use'; import { InlineLabel, Select, AsyncSelect, Input } from '@grafana/ui'; import { useShadowedState } from '../useShadowedState'; @@ -59,9 +59,6 @@ type SelReloadProps = { }; const SelReload = ({ loadOptions, allowCustomValue, onChange, onClose }: SelReloadProps): JSX.Element => { - const ref = useRef(null); - useClickAway(ref, onClose); - // here we rely on the fact that writing text into the // does not cause a re-render of the current react component. // this way there is only a single render-call, @@ -71,11 +68,12 @@ const SelReload = ({ loadOptions, allowCustomValue, onChange, onClose }: SelRelo // and probably have an useEffect const debouncedLoadOptions = debouncePromise(loadOptions, 1000, { leading: true }); return ( -
+
{ - const ref = useRef(null); const [loadState, doLoad] = useAsyncFn(loadOptions, [loadOptions]); - useClickAway(ref, onClose); useEffect(() => { doLoad(); }, [doLoad, loadOptions]); return ( -
+