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

How to distinguish autoClose from manual dismiss #1000

Open
demigor opened this issue Sep 12, 2023 · 1 comment
Open

How to distinguish autoClose from manual dismiss #1000

demigor opened this issue Sep 12, 2023 · 1 comment
Labels

Comments

@demigor
Copy link

demigor commented Sep 12, 2023

I'm struggling to remove toasts from Notification Center, that were manually closed (with close button click).

However, in onClose there is no way to distinguish wether the toast was closed automatically (via timeout) or by user action (close button click).

Tried with custom button, but the button does not receive any toast related properties, so there is no way to dismiss related toast from notification center in button's onClick event.

Any help would be appreciated.
Thank you

@ouassim2
Copy link

If you listen for the onChange event on toast it returns a ToastItem payload. Inside of it you can check the toast status property . When you click inside the toast, close the toast with x and on toast autoClose they ALL return status : removed

in my case there is no way for me to reproduce the onClick event which was working only when you click inside the toast and not on the x button.

In your case its the onClose that has the same status.

here is the link to try it out yourself : https://fkhadra.github.io/react-toastify/listen-for-changes

fkhadra added a commit that referenced this issue Nov 27, 2024
- solve: #1000, #716
- breaking: children props not passed down to `onClose` and `onOpen` callbacks
@fkhadra fkhadra added the Merged in next Merged but not live label Dec 10, 2024
@fkhadra fkhadra mentioned this issue Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants