Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset isClosePausedRef state after swipe #3355

Open
KelvinCodeK opened this issue Jan 29, 2025 · 0 comments
Open

Reset isClosePausedRef state after swipe #3355

KelvinCodeK opened this issue Jan 29, 2025 · 0 comments

Comments

@KelvinCodeK
Copy link

KelvinCodeK commented Jan 29, 2025

Bug report

Current Behavior

I'm using global context to manage my Toasts. I'm noticing that after removing the Toast on a swipe, the next toast stays in view infinitely because context.isClosePausedRef.current is never set to false again as hasToasts equates to false after the swipe event.

Expected behavior

I'd like to see the context.isClosePausedRef.current be reset if there are no Toasts available and it's still set to true

Suggested solution

in Toast.tsx, I think adding this code:

  if (!hasToasts && context.isClosePausedRef.current) {
    context.isClosePausedRef.current = false;
  }

above this line:

   if (hasToasts && wrapper && viewport) {

Could solve the issue. While debugging the node module file, I found that after a successful swipe that makes the toast disappear. There's a final event in the useEffect code that wraps the code above, where hasToasts is not available, making it so that the isClosePausedRef state can never be reset properly. It could be that my state mutations take a bit longer than the example Toast in the documentation, which would cause this behavior.

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-toast ^1.2.4
React n/a 18.2.0
Browser Chrome
Assistive tech
Node n/a
npm/yarn PNPM >=7.0.0 < 8.0.0
Operating System MacOs Sequoia 15.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant