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 onAutoClose not working #514

Closed
molvqingtai opened this issue Nov 8, 2024 · 1 comment
Closed

Loading onAutoClose not working #514

molvqingtai opened this issue Nov 8, 2024 · 1 comment

Comments

@molvqingtai
Copy link
Contributor

toast.loading('hello,world', {
  duration:1000,
  onAutoClose: ({ id }) => toast.dismiss(id) // Not called
})

When timed out, onAutoClose is not called

Related issues: #476

@ynng3
Copy link
Contributor

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.

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.

emilkowalski added a commit that referenced this issue Feb 18, 2025
* refactor: remove unstyled prop (#557)

* fix: allow toats to grow properly (#559)

* chore: rename data-theme to data-sonner-theme (#560)

* fix: toast removal in strict mode (#563)

* refactor: maintain default styles when custom (#564)

* fix: check for promise properly (#565)

* chore: horizontal swiping improvements (#566)

* medium font weight

* chore: improve rich colors (#567)

* chore: improve base colors (#568)

* improve colors

* improve base colors

* chore: remove lift interaction, decrease default gap (#569)

* v2.0.0-beta.1

* chore: update toast lifetime (#570)

* build: use bunchee (#561)

* fix: failing tests (#572)

* Fix tests

* fix tests

* fix: unstyled prop not being applied to all elements (#573)

* Improve unstyled prop

* Cleanup

* fix: inability to remove a toast that has just been created (#574)

* Prevent batching

* Cleanup

* hero cleanup

* fix: close button background is transparent (#575)

* chore: bring back lift on hover (#576)

* v2.0.0-beta.2

* chore: remove deprecated props (#577)

* feat: drag damping (#578)

* dampen darg

* Adjust swipe threshold

* typo

* Enhance Promise to support ExternalToast propertiesfeat: Promise enhancement to allow ExternalToast props (#547)

* fix: make promises work with new Error (#579)

* wip

* Add test for error classin promises

* chore: Hide the close button when toastType is loading (#516)

#514 #476

* fix close button aria labels (#490)

Co-authored-by: Emil Kowalski <[email protected]>

* fix: error promise test (#580)

* v2.0.0-beta.3

---------

Co-authored-by: Jiachi Liu <[email protected]>
Co-authored-by: Diego Traid <[email protected]>
Co-authored-by: 알노리 <[email protected]>
Co-authored-by: Miro Rauhala <[email protected]>
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

3 participants