Skip to content

Commit 04d8eb4

Browse files
committed
Add search input in variables
1 parent 4104713 commit 04d8eb4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

packages/twenty-front/src/modules/workflow/search-variables/components/SearchVariablesDropdownStepSubItem.tsx

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
22
import { StepOutputSchema } from '@/workflow/search-variables/types/StepOutputSchema';
33
import { isObject } from '@sniptt/guards';
4-
import { useState } from 'react';
4+
import { useMemo, useState } from 'react';
55
import { IconChevronLeft, MenuItemSelect } from 'twenty-ui';
6+
import { DropdownMenuSearchInput } from 'packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenuSearchInput';
67

78
type SearchVariablesDropdownStepSubItemProps = {
89
step: StepOutputSchema;
@@ -16,6 +17,7 @@ const SearchVariablesDropdownStepSubItem = ({
1617
onBack,
1718
}: SearchVariablesDropdownStepSubItemProps) => {
1819
const [currentPath, setCurrentPath] = useState<string[]>([]);
20+
const [searchInputValue, setSearchInputValue] = useState('');
1921

2022
const getSelectedObject = () => {
2123
let selected = step.outputSchema;
@@ -45,12 +47,29 @@ const SearchVariablesDropdownStepSubItem = ({
4547

4648
const headerLabel = currentPath.length === 0 ? step.name : currentPath.at(-1);
4749

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+
4862
return (
4963
<>
5064
<DropdownMenuHeader StartIcon={IconChevronLeft} onClick={goBack}>
5165
{headerLabel}
5266
</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]) => (
5473
<MenuItemSelect
5574
key={key}
5675
selected={false}

0 commit comments

Comments
 (0)