fix: error toasts persist until manually dismissed
All checks were successful
Build & Publish / publish (push) Successful in 1m11s
All checks were successful
Build & Publish / publish (push) Successful in 1m11s
Error variant toasts no longer auto-close after 5 seconds. Duration 0 means "no auto-dismiss". Other variants unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -81,8 +81,9 @@ export function ToastProvider({ children }: { children: ReactNode }) {
|
|||||||
const toast = useCallback(
|
const toast = useCallback(
|
||||||
(options: ToastOptions): string => {
|
(options: ToastOptions): string => {
|
||||||
const id = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`
|
const id = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`
|
||||||
const duration = options.duration ?? DEFAULT_DURATION
|
|
||||||
const variant = options.variant ?? 'info'
|
const variant = options.variant ?? 'info'
|
||||||
|
// Error toasts persist until manually dismissed; others auto-close after DEFAULT_DURATION
|
||||||
|
const duration = options.duration ?? (variant === 'error' ? 0 : DEFAULT_DURATION)
|
||||||
|
|
||||||
const newToast: ToastItem = {
|
const newToast: ToastItem = {
|
||||||
id,
|
id,
|
||||||
@@ -99,11 +100,13 @@ export function ToastProvider({ children }: { children: ReactNode }) {
|
|||||||
return next.slice(-MAX_TOASTS)
|
return next.slice(-MAX_TOASTS)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Schedule auto-dismiss
|
// Schedule auto-dismiss (duration 0 = persist until manual dismiss)
|
||||||
const timer = setTimeout(() => {
|
if (duration > 0) {
|
||||||
dismiss(id)
|
const timer = setTimeout(() => {
|
||||||
}, duration)
|
dismiss(id)
|
||||||
timersRef.current.set(id, timer)
|
}, duration)
|
||||||
|
timersRef.current.set(id, timer)
|
||||||
|
}
|
||||||
|
|
||||||
return id
|
return id
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user