1
1
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader' ;
2
2
import { StepOutputSchema } from '@/workflow/search-variables/types/StepOutputSchema' ;
3
3
import { isObject } from '@sniptt/guards' ;
4
- import { useState } from 'react' ;
4
+ import { useMemo , useState } from 'react' ;
5
5
import { IconChevronLeft , MenuItemSelect } from 'twenty-ui' ;
6
+ import { DropdownMenuSearchInput } from 'packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenuSearchInput' ;
6
7
7
8
type SearchVariablesDropdownStepSubItemProps = {
8
9
step : StepOutputSchema ;
@@ -16,6 +17,7 @@ const SearchVariablesDropdownStepSubItem = ({
16
17
onBack,
17
18
} : SearchVariablesDropdownStepSubItemProps ) => {
18
19
const [ currentPath , setCurrentPath ] = useState < string [ ] > ( [ ] ) ;
20
+ const [ searchInputValue , setSearchInputValue ] = useState ( '' ) ;
19
21
20
22
const getSelectedObject = ( ) => {
21
23
let selected = step . outputSchema ;
@@ -45,12 +47,29 @@ const SearchVariablesDropdownStepSubItem = ({
45
47
46
48
const headerLabel = currentPath . length === 0 ? step . name : currentPath . at ( - 1 ) ;
47
49
50
+ const options = Object . entries ( getSelectedObject ( ) ) ;
51
+
52
+ const filteredOptions = useMemo (
53
+ ( ) =>
54
+ searchInputValue
55
+ ? options . filter ( ( [ key ] ) =>
56
+ key . toLowerCase ( ) . includes ( searchInputValue . toLowerCase ( ) ) ,
57
+ )
58
+ : options ,
59
+ [ options , searchInputValue ] ,
60
+ ) ;
61
+
48
62
return (
49
63
< >
50
64
< DropdownMenuHeader StartIcon = { IconChevronLeft } onClick = { goBack } >
51
65
{ headerLabel }
52
66
</ DropdownMenuHeader >
53
- { Object . entries ( getSelectedObject ( ) ) . map ( ( [ key , value ] ) => (
67
+ < DropdownMenuSearchInput
68
+ autoFocus
69
+ value = { searchInputValue }
70
+ onChange = { ( event ) => setSearchInputValue ( event . target . value ) }
71
+ />
72
+ { filteredOptions . map ( ( [ key , value ] ) => (
54
73
< MenuItemSelect
55
74
key = { key }
56
75
selected = { false }
0 commit comments