diff --git a/frontend/src/components/SuccessNotification.tsx b/frontend/src/components/SuccessNotification.tsx index bef99b9..ee90cc0 100644 --- a/frontend/src/components/SuccessNotification.tsx +++ b/frontend/src/components/SuccessNotification.tsx @@ -14,30 +14,31 @@ export default function SuccessNotification({ onClose, action, }: SuccessNotificationProps) { - const dialogRef = useRef(null); + const notificationRef = useRef(null); const titleId = useId(); const descriptionId = useId(); useEffect(() => { - const dialog = dialogRef.current; - if (!dialog) return; - dialog.showModal(); + const notification = notificationRef.current; + if (!notification) return; + // Stay above the page without locking scrolling or moving keyboard focus. + notification.showPopover(); let exitAnimation: Animation | undefined; const timer = window.setTimeout(() => { - if (!dialog.open) return; + if (!notification.matches(":popover-open")) return; if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) { - dialog.close(); + notification.hidePopover(); return; } - exitAnimation = dialog.animate( + exitAnimation = notification.animate( [ { transform: "translateX(0)", opacity: 1 }, { transform: "translateX(calc(100% + 1rem))", opacity: 0 }, ], { duration: 250, easing: "ease-in", fill: "forwards" }, ); - exitAnimation.onfinish = () => dialog.close(); + exitAnimation.onfinish = () => notification.hidePopover(); }, 5000); return () => { window.clearTimeout(timer); @@ -46,16 +47,19 @@ export default function SuccessNotification({ }, []); return ( - { + if (event.newState === "closed") onClose(); + }} aria-labelledby={titleId} aria-describedby={descriptionId} className="fixed right-4 left-auto top-20 bottom-auto m-0 h-fit max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-sm overflow-y-auto rounded-2xl border border-surface bg-background p-0 text-white shadow-lg shadow-black/20 backdrop:bg-transparent motion-safe:animate-[feedback-slide-in_250ms_ease-out]" > + ); } diff --git a/frontend/src/components/buttons/AddToBuildButton.tsx b/frontend/src/components/buttons/AddToBuildButton.tsx index 808cb11..8107348 100644 --- a/frontend/src/components/buttons/AddToBuildButton.tsx +++ b/frontend/src/components/buttons/AddToBuildButton.tsx @@ -2,7 +2,6 @@ import type { ReactNode } from "react"; import { useRef, useState } from "react"; import type { PcPart } from "@/types/types"; import { useBuild } from "@/context/BuildContext"; -import { useNavigate } from "react-router"; import { twMerge } from "tailwind-merge"; import Button from "./Button"; import AddToBuildFeedback from "../AddToBuildFeedback";