1
- import React , { useCallback , useEffect , useState } from 'react' ;
2
- import type { FC } from 'react' ;
3
- import type { ChangeEvent } from 'react' ;
4
- import { useSelector , useDispatch } from 'react-redux' ;
1
+ import React , { useEffect , useState } from 'react' ;
5
2
6
3
import { UISearchBox } from '@sap-ux/ui-components' ;
7
4
@@ -17,20 +14,16 @@ import {
17
14
} from '../../../../state/reducers' ;
18
15
import { Filters } from '../Filters' ;
19
16
20
- const SEARCH_TIMEOUT = 250 ;
21
-
22
17
/**
23
18
*
24
19
* @returns An input field
25
20
*/
26
- export const SearchField : FC = ( ) : JSX . Element => {
27
- const dispatch = useDispatch ( ) ;
28
-
21
+ export const SearchField : React . FC = ( ) : JSX . Element => {
29
22
const networkStatus : string = useAppSelector ( getNetworkStatus ) ;
30
23
const productFilters : string [ ] = useAppSelector ( getProductFilters ) ;
31
24
const componentFilters : string [ ] = useAppSelector ( getComponentFilters ) ;
32
25
const activeScreen : string = useAppSelector ( getActiveScreen ) ;
33
- const activeSearch : string = useSelector ( getSearchQuery ) ;
26
+ const activeSearch : string = useAppSelector ( getSearchQuery ) ;
34
27
35
28
const [ searchTerm , setSearchTerm ] = useState < string > ( activeSearch ) ;
36
29
@@ -40,21 +33,12 @@ export const SearchField: FC = (): JSX.Element => {
40
33
}
41
34
} ;
42
35
43
- const onChange = ( _ ?: ChangeEvent < HTMLInputElement > | undefined , newSearchTerm = '' ) : void => {
44
- if ( ! / \S / . test ( newSearchTerm ) ) {
45
- newSearchTerm = '' ;
46
- }
47
- if ( activeSearch !== newSearchTerm ) {
48
- actions . setQueryValue ( newSearchTerm ) ;
49
- }
50
- } ;
51
-
52
36
const onSearch = ( searchItem : string ) : void => {
53
37
if ( ! / \S / . test ( searchItem ) ) {
54
38
searchItem = '' ;
55
39
}
56
40
if ( activeSearch !== searchItem ) {
57
- dispatch ( actions . setQueryValue ( searchItem ) ) ;
41
+ actions . setQueryValue ( searchItem ) ;
58
42
}
59
43
} ;
60
44
@@ -69,7 +53,7 @@ export const SearchField: FC = (): JSX.Element => {
69
53
component : componentFilters
70
54
} ,
71
55
{
72
- responseSize : 20 , //appState.pageSize,
56
+ responseSize : 20 ,
73
57
offset : 0
74
58
}
75
59
) ;
@@ -85,7 +69,6 @@ export const SearchField: FC = (): JSX.Element => {
85
69
placeholder = "Search Guided Answers"
86
70
id = "search-field"
87
71
onClear = { onClear }
88
- onChange = { onChange }
89
72
onSearch = { onSearch } > </ UISearchBox >
90
73
{ activeScreen === 'SEARCH' && < Filters /> }
91
74
</ div >
0 commit comments