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

Loading state preventing closeButton dismiss to work #476

Open
D-Rekk opened this issue Aug 2, 2024 · 1 comment
Open

Loading state preventing closeButton dismiss to work #476

D-Rekk opened this issue Aug 2, 2024 · 1 comment

Comments

@D-Rekk
Copy link

D-Rekk commented Aug 2, 2024

Describe the feature / bug 📝:

Currently closeButton is not working when toast is in loading state.

Steps to reproduce the bug 🔁:

  1. Go to https://sonner.emilkowal.ski/
  2. Click on Promise button
  3. Try to dismiss the toast using the closeButton while in loading state.
@ynng3
Copy link

ynng3 commented Nov 11, 2024

The reason a toast of type loading does not close is due to the condition set in the code. Specifically, in the Toast component, there are checks to prevent the automatic closing of a loading toast.

// https://github.com/emilkowalski/sonner/blob/main/src/index.tsx#L175
if ((toast.promise && toastType === 'loading') || toast.duration === Infinity || toast.type === 'loading') return;

This logic ensures that if the toast has a loading type, it will not proceed with the auto-close functionality.

If the toast is closed while loading, the user will not be able to see the completed result.
Therefore, it seems that closing is prevented.

So my opinion is that it doesn't seem to be a bug.

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

2 participants