-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
Allow "onClose" and "onExited" callbacks #21
Conversation
@nocksapp Could you give an example of a scenario where having access to |
Well, I needed the I created the PR more because I think that |
This will be merged for the next version of notistack. Thanks for the contribution @nocksapp ❤️ |
@nocksapp Functionality has been added to master branch, and will be included in the next release. Thanks for reporting this and the PR. ❤️ |
I have latest version 0.4.1 installed through npm, I don't see this PR is merged. |
@iamhosseindhv In commit a53a91d, the parameters in onClose callback is (event, reason, key), but in 728e004, the parameter is only (key). |
I see your point @zsh1313. However, there're only two possible reasons:
so basically notistack does the @nocksapp was right about what he mentioned previously, as at the time there was no support for with the current implementation there isn't a way of accessing |
It is not quite true that the custom callback func gets called ONLY if the reason is "timeout". I debugged the notistack code and found if there is action button and when clicking it, the reason is "undefined" and the passed onClose func gets called too. So basically there are two cases that the callback gets called: timeout & clicking action button. What I can think the benefits if pass the (event, reason) in the custom callback is like below
Hope that makes sense |
Fair enough @zsh1313. didn't know Anyhow, so line 21-23 would be?: if (reason === 'clickaway') return;
if (singleOnClose) singleOnClose(event, reason, key);
onClose(event, reason, key); (and |
That looks good @iamhosseindhv . |
👍🏼Appreciate if you could open a new issue for this. The fix will be published in the next version. @zsh1313 |
@iamhosseindhv Sorry for late reply. I have created a new issue about what we have discussed |
@zsh1313 Thanks 👍🏼 |
As global for all snacks on the SnackbarProvider and for single snacks created with enqueueSnackbar