diff --git a/src/Workspace.tsx b/src/Workspace.tsx index 5c456c3..fd31ec0 100644 --- a/src/Workspace.tsx +++ b/src/Workspace.tsx @@ -1,4 +1,4 @@ -import { use, useState } from "react"; +import { use, useEffect, useState } from "react"; import Modal, { useModal } from "./Modal"; import Select from "react-select"; import { SingleValue } from "react-select"; @@ -419,6 +419,12 @@ function WorkspaceSearch() { options = courses; } + // catalogs load asynchronously; re-sync the options whenever the catalog + // changes so the dropdown never shows stale or empty results + useEffect(() => { + setOptions(Object.values(indexedCourses)); + }, [indexedCourses]); + const [selectedCourse, setCourse] = useState>(null); const handleSelect = (courseData: SingleValue) => { @@ -447,7 +453,9 @@ function WorkspaceSearch() {