11// Libraries
2- import React , { ChangeEvent , FC , useContext } from 'react'
2+ import React , { ChangeEvent , FC , useContext , useState , useRef } from 'react'
33import { Input , IconFont } from '@influxdata/clockface'
44import { OperatorContext } from 'src/operator/context/operator'
55import { debounce } from 'lodash'
@@ -8,12 +8,14 @@ import {debounce} from 'lodash'
88import { OperatorRoutes } from 'src/operator/constants'
99
1010const ResourcesSearchbar : FC = ( ) => {
11- const { pathname, searchTerm, setSearchTerm} = useContext ( OperatorContext )
11+ const { pathname, setSearchTerm} = useContext ( OperatorContext )
12+ const [ searchText , setSearchText ] = useState ( '' )
1213
13- const debounceFunc = debounce ( setSearchTerm , 50 )
14+ const debounceFunc = useRef ( debounce ( setSearchTerm , 300 ) )
1415
1516 const changeSearchTerm = ( event : ChangeEvent < HTMLInputElement > ) => {
16- debounceFunc ( event . target . value )
17+ setSearchText ( event . target . value )
18+ debounceFunc . current ( event . target . value )
1719 }
1820
1921 const isOrgsTab = pathname . includes ( OperatorRoutes . organizations )
@@ -27,7 +29,7 @@ const ResourcesSearchbar: FC = () => {
2729 isOrgsTab === 'organizations' ? 'id' : 'email'
2830 } ...`}
2931 inputStyle = { { width : '500px' } }
30- value = { searchTerm }
32+ value = { searchText }
3133 onChange = { changeSearchTerm }
3234 testID = "operator-resource--searchbar"
3335 />
0 commit comments