Skip to content

Commit

Permalink
Remove broken hover behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Oct 7, 2024
1 parent 7340e69 commit fd91ffa
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions apps/web/src/components/profileDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,9 @@ export function ProfileDropdown() {
const { user } = useAuth();
const buttonRef = useRef<HTMLButtonElement | null>(null);
const dropdownRef = useRef<HTMLDivElement | null>(null);
const timeoutDuration = 200;
let timeoutId: ReturnType<typeof setTimeout>;

if (!user) return null;

const openMenu = () => buttonRef?.current?.click();
const closeMenu = () =>
dropdownRef?.current?.dispatchEvent(
new KeyboardEvent("keydown", {
key: "Escape",
bubbles: true,
cancelable: true,
}),
);

const onMouseEnter = (closed?: boolean) => {
if (timeoutId) clearTimeout(timeoutId);
if (closed) openMenu();
};
const onMouseLeave = (open: boolean) => {
if (open) {
timeoutId = setTimeout(() => closeMenu(), timeoutDuration);
}
};

return (
<Menu as="div" className="menu hidden sm:block">
{({ open }) => (
Expand All @@ -55,14 +33,11 @@ export function ProfileDropdown() {
? "rounded-b-none rounded-t bg-slate-800 text-white"
: "text-muted rounded",
)}
onClick={openMenu}
as={Link}
href={`/users/${user.username}`}
onMouseEnter={() => onMouseEnter(!open)}
onMouseLeave={() => onMouseLeave(open)}
>
<span className="sr-only">Open user menu</span>
<div className="h-8 w-8 sm:h-8 sm:w-8">
<div className="h-8 w-8">
<UserAvatar user={user} />
</div>
</MenuButton>
Expand All @@ -77,8 +52,6 @@ export function ProfileDropdown() {
>
<MenuItems
ref={dropdownRef}
onMouseEnter={() => onMouseEnter()}
onMouseLeave={() => onMouseLeave(open)}
static
className="absolute right-0 z-40 mt-0 w-48 origin-top-right divide-y divide-slate-700"
>
Expand Down

0 comments on commit fd91ffa

Please sign in to comment.