From 8ff4ba0c70c471e7923a6a01681500197d209bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B1=E3=82=A4=E3=83=A9?= Date: Mon, 15 Sep 2025 09:29:25 -0600 Subject: [PATCH] fix: scroll item list into view when opening `MultiSelectCombobox` (#19806) --- .../MultiSelectCombobox/MultiSelectCombobox.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/site/src/components/MultiSelectCombobox/MultiSelectCombobox.tsx b/site/src/components/MultiSelectCombobox/MultiSelectCombobox.tsx index c1e518c3a3..06b2660df2 100644 --- a/site/src/components/MultiSelectCombobox/MultiSelectCombobox.tsx +++ b/site/src/components/MultiSelectCombobox/MultiSelectCombobox.tsx @@ -216,6 +216,7 @@ export const MultiSelectCombobox = forwardRef< const [onScrollbar, setOnScrollbar] = useState(false); const [isLoading, setIsLoading] = useState(false); const dropdownRef = useRef(null); + const listRef = useRef(null); const [selected, setSelected] = useState( arrayDefaultOptions ?? [], @@ -364,6 +365,15 @@ export const MultiSelectCombobox = forwardRef< void exec(); }, [debouncedSearchTerm, groupBy, open, triggerSearchOnFocus, onSearch]); + // Scroll dropdown into view on open + useEffect(() => { + if (!open || !listRef.current) { + return; + } + + listRef.current.scrollIntoView({ behavior: "smooth" }); + }, [open]); + const CreatableItem = () => { if (!creatable) { return undefined; @@ -603,7 +613,7 @@ export const MultiSelectCombobox = forwardRef< -
+
{open && (