Menu: fix #47, skip animateOpen if animating

This commit is contained in:
thislight 2024-11-20 00:27:52 +08:00
parent a69a5c31e5
commit 9a7710c070
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
3 changed files with 124 additions and 73 deletions

View file

@ -7,11 +7,7 @@ import {
ListItemText,
MenuItem,
} from "@suid/material";
import {
Show,
createUniqueId,
type ParentComponent,
} from "solid-js";
import { Show, createUniqueId, type ParentComponent } from "solid-js";
import {
Settings as SettingsIcon,
Bookmark as BookmarkIcon,
@ -39,9 +35,7 @@ const ProfileMenuButton: ParentComponent<{
const [open, state] = createManagedMenuState();
const onClick = (
event: MouseEvent & { currentTarget: HTMLButtonElement },
) => {
const onClick = (event: { currentTarget: HTMLElement }) => {
open(event.currentTarget.getBoundingClientRect());
};
@ -54,8 +48,8 @@ const ProfileMenuButton: ParentComponent<{
sx={{ borderRadius: "50%" }}
id={buttonId}
onClick={onClick}
aria-controls={open() ? menuId : undefined}
aria-expanded={open() ? "true" : undefined}
aria-controls={state.open ? menuId : undefined}
aria-expanded={state.open ? "true" : "false"}
>
<Avatar
alt={`${inf()?.displayName}'s avatar`}