diff --git a/src/components/planner/CreditsWarnHoverCard.tsx b/src/components/planner/CreditsWarnHoverCard.tsx index 24ec263e5..82f236bd3 100644 --- a/src/components/planner/CreditsWarnHoverCard.tsx +++ b/src/components/planner/CreditsWarnHoverCard.tsx @@ -13,7 +13,7 @@ export const CreditsWarnHoverCard: FC = ({ side = 'top', children, }) => ( - + {children} { @@ -36,7 +36,7 @@ export interface SemesterCourseItemProps extends ComponentPropsWithoutRef<'div'> /** UI implementation of a semester course */ /* eslint-disable react/prop-types */ -export const MemoizedSemesterCourseItem = React.memo( +export const MemoizedSemesterCourseItem = memo( forwardRef(function SemesterCourseItem( { course, @@ -86,7 +86,7 @@ export const MemoizedSemesterCourseItem = React.memo( }} onMouseEnter={() => { if (!dropdownOpen && !course.locked && !semesterLocked) - hoverTimer.current = setTimeout(() => setHoverOpen(true), 500); + hoverTimer.current = setTimeout(() => setHoverOpen(true), 700); setHoverEllipse(true); }} onMouseLeave={() => { @@ -157,13 +157,7 @@ export const MemoizedSemesterCourseItem = React.memo( {!semesterLocked && ( { - if (hoverOpen) { - setHoverOpen(false); - } - if (!open) setHoverEllipse(false); - setDropdownOpen(open); - }} + onOpenChange={setDropdownOpen} locked={course.locked} onPrereqOverrideChange={() => onPrereqOverrideChange && onPrereqOverrideChange(!course.prereqOveridden) @@ -179,7 +173,6 @@ export const MemoizedSemesterCourseItem = React.memo( className={`mr-2 rounded-md px-2 py-3 hover:cursor-default ${ course.locked ? 'hover:bg-gray-300' : 'hover:bg-gray-200/[.5]' }`} - onClick={() => setDropdownOpen(true)} > {!semesterLocked && ( = ({ ); }; -export default React.memo(DraggableSemesterCourseItem); +export default memo(DraggableSemesterCourseItem); diff --git a/src/components/planner/Tiles/SemesterCourseItemDropdown.tsx b/src/components/planner/Tiles/SemesterCourseItemDropdown.tsx index e9d0ae91b..7d286f22d 100644 --- a/src/components/planner/Tiles/SemesterCourseItemDropdown.tsx +++ b/src/components/planner/Tiles/SemesterCourseItemDropdown.tsx @@ -1,5 +1,5 @@ import * as DropdownMenu from '@radix-ui/react-dropdown-menu'; -import { FC } from 'react'; +import { FC, useRef } from 'react'; import { v4 as uuidv4 } from 'uuid'; import ChevronIcon from '@/icons/ChevronIcon'; @@ -17,6 +17,8 @@ const contentClasses = 'w-64 rounded-md border border-neutral-300 bg-generic-whi const disabledClasses = 'text-black/25 cursor-default'; +const DROPDOWN_OPEN_DELAY_MS = 600; + export interface SemesterTileDropdownProps { deleteCourse: () => void; changeColor: (color: keyof typeof tagColors) => void; @@ -43,10 +45,23 @@ const SemesterCourseItemDropdown: FC = ({ prereqOverriden, onPrereqOverrideChange, }) => { - const id = uuidv4(); + const hoverTimer = useRef | null>(null); + return ( - + { + hoverTimer.current = setTimeout(() => { + onOpenChange(true); + hoverTimer.current = null; + }, DROPDOWN_OPEN_DELAY_MS); + }} + onPointerLeave={() => { + if (hoverTimer.current) clearTimeout(hoverTimer.current); + }} + data-no-dnd="true" + asChild + > {children} @@ -54,7 +69,7 @@ const SemesterCourseItemDropdown: FC = ({ = ({ {Object.entries(tagColors).map(([color, classes]) => ( changeColor(color as keyof typeof tagColors)} >