Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(frontend): forward Combobox ref to its input (#8831)

Andrew Huanga29e3d87a8b5
diff --git a/frontend/src/components/v3/generic/Combobox/Combobox.tsx b/frontend/src/components/v3/generic/Combobox/Combobox.tsx
index 6cecf01d00..3cb776ba3f 100644
--- a/frontend/src/components/v3/generic/Combobox/Combobox.tsx
+++ b/frontend/src/components/v3/generic/Combobox/Combobox.tsx
@@ -140,7 +140,7 @@ type ComboboxSharedProps<TOption> = {
};
type ComboboxInputProps = Omit<
- React.ComponentPropsWithoutRef<"input">,
+ React.ComponentProps<"input">,
"children" | "disabled" | "multiple" | "onChange" | "type" | "value"
>;
@@ -923,10 +923,12 @@ const SingleCombobox = <TOption,>(props: ComboboxSingleProps<TOption>) => {
onClick,
onFocus,
onKeyDown,
+ ref,
...inputProps
} = props;
const isInsideOverlayLayer = useIsInsideOverlayLayer();
const inputRef = React.useRef<HTMLInputElement | null>(null);
+ React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);
const listScrollRef = React.useRef<HTMLDivElement>(null);
const highlightedOptionValueRef = React.useRef<string | null>(null);
const [open, setOpen, markPopupDismissEvent] = useComboboxOpen(onPopupOpenChange);
@@ -1323,10 +1325,12 @@ const MultipleCombobox = <TOption,>({
"aria-label": ariaLabel,
"aria-labelledby": ariaLabelledBy,
onKeyDown,
+ ref,
...inputProps
}: ComboboxMultipleProps<TOption>) => {
const isInsideOverlayLayer = useIsInsideOverlayLayer();
const inputRef = React.useRef<HTMLInputElement | null>(null);
+ React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);
const listScrollRef = React.useRef<HTMLDivElement>(null);
const chipsRef = React.useRef<HTMLDivElement | null>(null);
const { scrollEdges, setViewportRef } = useScrollEdges<HTMLDivElement>(