diff --git a/src/components/planner/sidebar/CoursesController/ClassSelector.tsx b/src/components/planner/sidebar/CoursesController/ClassSelector.tsx index 52db2bf5..a43c9114 100644 --- a/src/components/planner/sidebar/CoursesController/ClassSelector.tsx +++ b/src/components/planner/sidebar/CoursesController/ClassSelector.tsx @@ -17,15 +17,12 @@ const ClassSelector = ({ course }: Props) => { const classSelectorContentRef = useRef(null) const { multipleOptions, setMultipleOptions, selectedOption } = useContext(MultipleOptionsContext) - const [selectedClassId, setSelectedClassId] = useState(null); - const courseOption: CourseOption = multipleOptions[selectedOption].course_options.find((opt) => opt.course_id === course.id) - const [locked, setLocked] = useState(courseOption?.locked) - const [preview, setPreview] = useState(null) const [display, setDisplay] = useState(courseOption?.picked_class_id) + const [isDropdownOpen, setIsDropdownOpen] = useState(false); useEffect(() => { const course_options = multipleOptions[selectedOption].course_options; @@ -88,10 +85,9 @@ const ClassSelector = ({ course }: Props) => {

{/* Dropdown Menu */} - { - if (!open) { - removePreview(); - } + { + setIsDropdownOpen(open); + if (!open) removePreview(); }}>
@@ -111,6 +107,7 @@ const ClassSelector = ({ course }: Props) => { >] + isDropdownOpen: boolean setPreview: Dispatch> - removePreview: () => void, + removePreview: () => void contentRef: any triggerRef: any } @@ -48,6 +49,7 @@ const NoOptionsFound = ({ mobile }: { mobile: boolean }) => { const ClassSelectorDropdownController = ({ course, selectedClassIdHook, + isDropdownOpen, setPreview, removePreview, contentRef, @@ -229,7 +231,7 @@ const ClassSelectorDropdownController = ({ setSelectedClassId(classInfo.id) setPreview(null) }} - onMouseEnter={() => showPreview(classInfo)} + onMouseEnter={() => { if (isDropdownOpen) showPreview(classInfo) }} onMouseLeave={() => removePreview()} /> ))} @@ -263,7 +265,7 @@ const ClassSelectorDropdownController = ({ setSelectedClassId(classInfo.id) setPreview(null) }} - onMouseEnter={() => showPreview(classInfo)} + onMouseEnter={() => { if (isDropdownOpen) showPreview(classInfo) }} onMouseLeave={() => removePreview()} /> ))}