@@ -3,7 +3,7 @@ import { useHistory, useLocation } from 'react-router-dom'
3
3
import { ReactComponent as Search } from '../../assets/icons/ic-search.svg'
4
4
import { ReactComponent as Clear } from '../../assets/icons/ic-error.svg'
5
5
import { handleUTCTime } from '../common'
6
- import { Progressing } from '@devtron-labs/devtron-fe-common-lib'
6
+ import { CustomInput , Progressing , SearchBar } from '@devtron-labs/devtron-fe-common-lib'
7
7
import { ClusterDetail } from './types'
8
8
import { ReactComponent as Error } from '../../assets/icons/ic-error-exclamation.svg'
9
9
import { ReactComponent as Success } from '../../assets/icons/appstatus/healthy.svg'
@@ -73,37 +73,36 @@ export default function ClusterSelectionList({
73
73
setSearchText ( '' )
74
74
}
75
75
76
- const handleFilterKeyPress = ( event ) : void => {
77
- const theKeyCode = event . key
78
- if ( theKeyCode === 'Enter' ) {
79
- handleFilterChanges ( event . target . value )
76
+ const handleFilterKeyPress = ( value ) : void => {
77
+ handleFilterChanges ( value )
80
78
setSearchApplied ( true )
81
- } else if ( theKeyCode === 'Backspace' && searchText . length === 1 ) {
82
- clearSearch ( )
83
- }
79
+ }
80
+
81
+ const handleSearchChange = ( value ) : void => {
82
+ setSearchText ( value )
83
+ }
84
+
85
+ const handleOnBlur = ( event ) : void => {
86
+ event . stopPropagation ( )
87
+ let _searchText = event . target . value
88
+ _searchText = _searchText ?. trim ( )
89
+ handleFilterChanges ( _searchText )
90
+ setSearchText ( _searchText )
84
91
}
85
92
86
93
const renderSearch = ( ) : JSX . Element => {
87
94
return (
88
- < div className = "search dc__position-rel margin-right-0 en-2 bw-1 br-4 h-32" >
89
- < Search className = "search__icon icon-dim-18" />
90
- < input
91
- type = "text"
92
- placeholder = "Search clusters"
93
- value = { searchText }
94
- className = "search__input"
95
- onChange = { ( event ) => {
96
- setSearchText ( event . target . value )
97
- } }
98
- onKeyDown = { handleFilterKeyPress }
99
- disabled = { clusterListLoader }
100
- />
101
- { searchApplied && (
102
- < button className = "search__clear-button" type = "button" onClick = { clearSearch } >
103
- < Clear className = "icon-dim-18 icon-n4 dc__vertical-align-middle" />
104
- </ button >
105
- ) }
106
- </ div >
95
+ < SearchBar
96
+ initialSearchText = { searchText }
97
+ handleSearchChange = { handleSearchChange }
98
+ handleEnter = { handleFilterKeyPress }
99
+ containerClassName = "w-250-imp"
100
+ inputProps = { {
101
+ placeholder : 'Search clusters' ,
102
+ autoFocus : true ,
103
+ } }
104
+ handleOnBlur = { handleOnBlur }
105
+ />
107
106
)
108
107
}
109
108
0 commit comments