diff --git a/components/TempDesignSystem/Form/Select/index.tsx b/components/TempDesignSystem/Form/Select/index.tsx index 2319daa8a..e84e8e568 100644 --- a/components/TempDesignSystem/Form/Select/index.tsx +++ b/components/TempDesignSystem/Form/Select/index.tsx @@ -1,5 +1,5 @@ "use client" -import { RefObject, useEffect, useRef, useState } from "react" +import { useState } from "react" import { Button, type Key, @@ -15,7 +15,7 @@ import SelectChevron from "../SelectChevron" import styles from "./select.module.css" -import type { SelectProps } from "./select" +import type { SelectPortalContainer, SelectProps } from "./select" export default function Select({ "aria-label": ariaLabel, @@ -26,18 +26,20 @@ export default function Select({ value, defaultSelectedKey, }: SelectProps) { - const ref = useRef(null) - const [rootDiv, setRootDiv] = useState(null) - useEffect(() => { - setRootDiv(ref.current) - }, [setRootDiv]) + const [rootDiv, setRootDiv] = useState(null) + + function setRef(node: SelectPortalContainer) { + if (node) { + setRootDiv(node) + } + } function handleOnSelect(key: Key) { onSelect(key) } return ( -
+