fix(toast): remove shake class before hiding to ensure animationend fires

When dismiss() was called on a persistent+shaking toast, the .shake CSS
rule (declared after .hiding) overrode toast-out animation. If shake had
already finished, no animationend fired and the element was never removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
caoqianming 2026-03-25 13:16:50 +08:00
parent b7d55fed81
commit 2a247dd70b
1 changed files with 1 additions and 0 deletions

View File

@ -42,6 +42,7 @@ export function showToast(title, { message, level = "error", duration = 4000, sh
const dismiss = () => {
if (!el.parentNode) return;
el.classList.remove("shake");
el.classList.add("hiding");
el.addEventListener("animationend", () => el.remove(), { once: true });
};