Open
Description
🙋 Feature Request
Provide timer state (ex. isRunning) for toast.
🤔 Expected Behavior
A toast.timer
provide state of current timer.
😯 Current Behavior
A toast.timer
has private property timerId
for check timer state.
💁 Possible Solution
Add property isRunning
for Timer
(or state="running | paused"
):
react-spectrum/packages/@react-stately/toast/src/useToastState.ts
Lines 205 to 209 in a30e1bf
🔦 Context
I create toasts with progress bar and when toast is hovered we can't stop animation because timer api doesn't have current state.
💻 Examples
function Snackbar<T>(props: ToastProps<T>) {
const { toast } = props;
// @ts-expect-error (timerId is private API)
const timerId = toast?.timer?.timerId;
return (
<div className={styles.root}>
<div
className={styles.progress}
style={{
animationDuration: `${toast.timeout}ms`,
animationPlayState: timerId === null ? "paused" : "running",
// Better solution:
// animationPlayState: toast.timer.isRunning ? "running" : "paused",
}}
/>
</div>
);
}
🧢 Your Company/Team
Yandex
🎁 Tracking Ticket (optional)
N/A
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
📋 Waiting for Sprint