Skip to content

Commit

Permalink
Developing the combobox component.
Browse files Browse the repository at this point in the history
  • Loading branch information
ser888gio committed Nov 28, 2024
1 parent 1ca3b5f commit 1247d22
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const Combobox = forwardRef<
if (!selectedValues.includes(valueToAdd)) {
const newSelectedValues = [...selectedValues, valueToAdd];
console.log("Setting new selectedValues:", newSelectedValues);
//Tells the parz
//Tells the par
setSelectedValues(newSelectedValues);
setQuery(""); // Clear query after selection

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ const Combobox = forwardRef<
options,
...props
},
ref
ref,
) => {
//Use state for selecting values. If nothing is provided, defaultValue will become the selected value
const [selectedValue, setSelectedValue] = useState<string | null>(
defaultValue || null
defaultValue || null,
);

const [query, setQuery] = useState<string>(defaultValue || "");
const [filteredOptions, setFilteredOptions] = useState(options);

useEffect(() => {
const filtered = options.filter((option) =>
option.label.toLowerCase().includes(query.toLowerCase())
option.label.toLowerCase().includes(query.toLowerCase()),
);
setFilteredOptions(filtered);
}, [query, options]);
Expand Down Expand Up @@ -138,7 +138,7 @@ const Combobox = forwardRef<
</Options>
</ComboboxPrimitive>
);
}
},
);

export { Combobox, Input };
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const SingleSelectField = forwardRef<React.ElementRef<typeof Input>, Props>(
{hasError && <Description state="error">{error}</Description>}
</Field>
);
}
},
);

export { SingleSelectField };

0 comments on commit 1247d22

Please sign in to comment.