Skip to content

Commit

Permalink
fix: class selection now always sets the correct class on the schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaspalma committed Sep 19, 2024
1 parent 46678c6 commit 97cb10a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
57 changes: 27 additions & 30 deletions src/components/planner/sidebar/CoursesController/ClassSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,38 +93,35 @@ const ClassSelector = ({ course }: Props) => {
</p>
<div className="flex items-center">
{/* Dropdown Menu */}
<DropdownMenu onOpenChange={(open: boolean) => {
setIsDropdownOpen(open);
if (!open) {
removePreview();
}
<DropdownMenu open={isDropdownOpen} onOpenChange={(open: boolean) => {
setIsDropdownOpen(open)
if (!open) removePreview();
}}>
<div className="w-full">
<DropdownMenuTrigger asChild disabled={courseOption?.locked} ref={classSelectorTriggerRef}>
<Button
variant="outline"
size="sm"
className="w-full justify-between truncate bg-lightish text-xs font-normal tracking-tighter hover:bg-primary/75 hover:text-white dark:bg-darkish"
>
<span className={`${selectedClassId === null ? "opacity-50" : ""}`}>{getClassDisplayText(course, selectedClassId)}</span>
{!courseOption?.locked && <ChevronUpDownIcon className="text-blackish h-6 w-6 dark:text-lightish" />}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
className="bg-lightish text-darkish dark:bg-darkish dark:text-lightish"
ref={classSelectorContentRef}
<DropdownMenuTrigger asChild disabled={courseOption?.locked} ref={classSelectorTriggerRef}>
<Button
variant="outline"
size="sm"
className="w-full justify-between truncate bg-lightish text-xs font-normal tracking-tighter hover:bg-primary/75 hover:text-white dark:bg-darkish"
>
<ClassSelectorDropdownController
course={course}
selectedClassIdHook={[selectedClassId, setSelectedClassId]}
previewHook={[preview, setPreview]}
display={display}
removePreview={removePreview}
contentRef={classSelectorContentRef}
triggerRef={classSelectorTriggerRef}
/>
</DropdownMenuContent>
</div>
<span className={`${selectedClassId === null ? "opacity-50" : ""}`}>{getClassDisplayText(course, selectedClassId)}</span>
{!courseOption?.locked && <ChevronUpDownIcon className="text-blackish h-6 w-6 dark:text-lightish" />}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
className="bg-lightish text-darkish dark:bg-darkish dark:text-lightish"
ref={classSelectorContentRef}
>
<ClassSelectorDropdownController
course={course}
isDropdownOpen={isDropdownOpen}
selectedClassIdHook={[selectedClassId, setSelectedClassId]}
previewHook={[preview, setPreview]}
display={display}
removePreview={removePreview}
contentRef={classSelectorContentRef}
triggerRef={classSelectorTriggerRef}
/>
</DropdownMenuContent>
</DropdownMenu>

{/* Lock Button */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ProfessorItem from "./ProfessorItem";
type Props = {
course: CourseInfo
selectedClassIdHook: [number | null, Dispatch<SetStateAction<number | null>>]
isDropdownOpen: boolean
previewHook: [number | null, Dispatch<SetStateAction<number | null>>]
display: number
removePreview: Function
Expand Down Expand Up @@ -49,6 +50,7 @@ const NoOptionsFound = ({ mobile }: { mobile: boolean }) => {
const ClassSelectorDropdownController = ({
course,
selectedClassIdHook,
isDropdownOpen,
previewHook,
display,
removePreview,
Expand Down Expand Up @@ -235,7 +237,9 @@ const ClassSelectorDropdownController = ({
setSelectedClassId(classInfo.id)
setPreview(null)
}}
onMouseEnter={() => showPreview(classInfo)}
onMouseEnter={() => {
if (isDropdownOpen) showPreview(classInfo);
}}
onMouseLeave={() => removePreview()}
/>
))}
Expand Down Expand Up @@ -272,7 +276,7 @@ const ClassSelectorDropdownController = ({
setSelectedClassId(classInfo.id)
setPreview(null)
}}
onMouseEnter={() => showPreview(classInfo)}
onMouseEnter={() => { if (isDropdownOpen) showPreview(classInfo) }}
onMouseLeave={() => removePreview()}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const CollabModal = ({ isOpen, closeModal }) => {
link: `https://collab.app/session/${Date.now().toString()}`,
participants: ['TheCreator'],
};
console.log('CollabModal -> newSession', newSession);

setSessions(prevSessions => [...prevSessions, newSession]);
setcurrentSessionId(newSession.id);
setCurrentView(SESSION);
Expand Down Expand Up @@ -135,4 +135,4 @@ const CollabModal = ({ isOpen, closeModal }) => {
);
};

export default CollabModal;
export default CollabModal;

0 comments on commit 97cb10a

Please sign in to comment.