Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions site/src/components/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface ComboboxProps {
onInputChange?: (value: string) => void;
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
onSelect: (value: string) => void;
id?: string;
}

type ComboboxOption = {
Expand All @@ -53,6 +54,7 @@ export const Combobox: FC<ComboboxProps> = ({
onInputChange,
onKeyDown,
onSelect,
id,
}) => {
const [managedOpen, setManagedOpen] = useState(false);
const [managedInputValue, setManagedInputValue] = useState("");
Expand All @@ -78,6 +80,7 @@ export const Combobox: FC<ComboboxProps> = ({
<Popover open={isOpen} onOpenChange={handleOpenChange}>
<PopoverTrigger asChild>
<Button
id={id}
variant="outline"
aria-expanded={isOpen}
className="w-full justify-between group"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ interface MultiSelectComboboxProps {
>;
/** hide or show the button that clears all the selected options. */
hideClearAllButton?: boolean;
/** Test ID for testing purposes */
"data-testid"?: string;
}

interface MultiSelectComboboxRef {
Expand Down Expand Up @@ -205,6 +207,7 @@ export const MultiSelectCombobox = forwardRef<
commandProps,
inputProps,
hideClearAllButton = false,
"data-testid": dataTestId,
}: MultiSelectComboboxProps,
ref,
) => {
Expand Down Expand Up @@ -454,6 +457,7 @@ export const MultiSelectCombobox = forwardRef<
<Command
ref={dropdownRef}
{...commandProps}
data-testid={dataTestId}
onKeyDown={(e) => {
handleKeyDown(e);
commandProps?.onKeyDown?.(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
case "dropdown": {
return (
<Combobox
id={id}
value={value ?? ""}
onSelect={(value) => onChange(value)}
options={parameter.options.map((option) => ({
Expand Down Expand Up @@ -497,7 +498,10 @@ const ParameterField: FC<ParameterFieldProps> = ({

return (
<MultiSelectCombobox
inputProps={{ id }}
inputProps={{
id: id,
}}
data-testid={`multiselect-${parameter.name}`}
options={options}
defaultOptions={selectedOptions}
onChange={(newValues) => {
Expand Down
Loading
Loading