1
1
import { useTheme } from "@emotion/react" ;
2
2
import CheckOutlined from "@mui/icons-material/CheckOutlined" ;
3
- import CloseOutlined from "@mui/icons-material/CloseOutlined" ;
4
3
import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown" ;
5
4
import OpenInNewOutlined from "@mui/icons-material/OpenInNewOutlined" ;
6
- import SearchOutlined from "@mui/icons-material/SearchOutlined" ;
7
5
import Button , { type ButtonProps } from "@mui/material/Button" ;
8
6
import Divider from "@mui/material/Divider" ;
9
- import IconButton from "@mui/material/IconButton" ;
10
- import InputAdornment from "@mui/material/InputAdornment" ;
11
7
import Menu , { type MenuProps } from "@mui/material/Menu" ;
12
8
import MenuItem from "@mui/material/MenuItem" ;
13
9
import MenuList from "@mui/material/MenuList" ;
14
10
import Skeleton , { type SkeletonProps } from "@mui/material/Skeleton" ;
15
- import TextField from "@mui/material/TextField" ;
16
- import Tooltip from "@mui/material/Tooltip" ;
17
11
import {
18
12
type FC ,
19
13
type ReactNode ,
@@ -35,6 +29,7 @@ import {
35
29
SearchInput ,
36
30
searchStyles ,
37
31
} from "components/Search/Search" ;
32
+ import { SearchField } from "components/SearchField/SearchField" ;
38
33
import { useDebouncedFunction } from "hooks/debounce" ;
39
34
import type { useFilterMenu } from "./menu" ;
40
35
import type { BaseOption } from "./options" ;
@@ -199,7 +194,6 @@ export const Filter: FC<FilterProps> = ({
199
194
} , [ filter . query ] ) ;
200
195
201
196
const shouldDisplayError = hasError ( error ) && isApiValidationError ( error ) ;
202
- const hasFilterQuery = filter . query !== "" ;
203
197
204
198
return (
205
199
< div
@@ -226,25 +220,23 @@ export const Filter: FC<FilterProps> = ({
226
220
learnMoreLabel2 = { learnMoreLabel2 }
227
221
learnMoreLink2 = { learnMoreLink2 }
228
222
/>
229
- < TextField
223
+ < SearchField
230
224
fullWidth
231
225
error = { shouldDisplayError }
232
226
helperText = {
233
227
shouldDisplayError
234
228
? getValidationErrorMessage ( error )
235
229
: undefined
236
230
}
237
- size = "small"
231
+ placeholder = "Search..."
232
+ value = { queryCopy }
233
+ onChange = { ( query ) => {
234
+ setQueryCopy ( query ) ;
235
+ filter . debounceUpdate ( query ) ;
236
+ } }
238
237
InputProps = { {
239
- "aria-label" : "Filter" ,
240
- name : "query" ,
241
- placeholder : "Search..." ,
242
- value : queryCopy ,
243
238
ref : textboxInputRef ,
244
- onChange : ( e ) => {
245
- setQueryCopy ( e . target . value ) ;
246
- filter . debounceUpdate ( e . target . value ) ;
247
- } ,
239
+ "aria-label" : "Filter" ,
248
240
onBlur : ( ) => {
249
241
if ( queryCopy !== filter . query ) {
250
242
setQueryCopy ( filter . query ) ;
@@ -258,40 +250,10 @@ export const Filter: FC<FilterProps> = ({
258
250
"&:hover" : {
259
251
zIndex : 2 ,
260
252
} ,
261
- "& input::placeholder" : {
262
- color : theme . palette . text . secondary ,
263
- } ,
264
- "& .MuiInputAdornment-root" : {
265
- marginLeft : 0 ,
266
- } ,
267
253
"&.Mui-error" : {
268
254
zIndex : 3 ,
269
255
} ,
270
256
} ,
271
- startAdornment : (
272
- < InputAdornment position = "start" >
273
- < SearchOutlined
274
- css = { {
275
- fontSize : 14 ,
276
- color : theme . palette . text . secondary ,
277
- } }
278
- />
279
- </ InputAdornment >
280
- ) ,
281
- endAdornment : hasFilterQuery && (
282
- < InputAdornment position = "end" >
283
- < Tooltip title = "Clear filter" >
284
- < IconButton
285
- size = "small"
286
- onClick = { ( ) => {
287
- filter . update ( "" ) ;
288
- } }
289
- >
290
- < CloseOutlined css = { { fontSize : 14 } } />
291
- </ IconButton >
292
- </ Tooltip >
293
- </ InputAdornment >
294
- ) ,
295
257
} }
296
258
/>
297
259
</ div >
0 commit comments