terry-staging #16

Merged
terry merged 96 commits from terry-staging into main 2026-06-05 16:33:12 +00:00
Showing only changes of commit efaf92c4e4 - Show all commits

View File

@@ -32,6 +32,7 @@ export function useToast(): ToastContextValue {
}
const AUTO_DISMISS_MS = 3000;
const MAX_VISIBLE_TOASTS = 2;
/**
* App-level toast host. Renders an aria-live region so screen readers announce
@@ -49,7 +50,9 @@ export function ToastProvider({ children }: { children: ReactNode }) {
const showToast = useCallback(
(message: string, variant: ToastVariant = "success") => {
const id = (idRef.current += 1);
setToasts((prev) => [...prev, { id, message, variant }]);
setToasts((prev) =>
[...prev, { id, message, variant }].slice(-MAX_VISIBLE_TOASTS),
);
window.setTimeout(() => dismiss(id), AUTO_DISMISS_MS);
},
[dismiss],