Allow overriding "reason" in closeSnackbar #620
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolving issue found in: #591
This PR allows you to override closeSnackbar reason, so you can act in
onClose
depending if user closed the snackbar himself or if it was for any other reason - like changing views and hiding snackbar.This is useful if you want to be sure that user saw a snackbar, if user closed it himself you can save it to localStorage / DB.
The reason why you would want to close the snackbar while changing views is quite simple - context often matters and displaying same snackbar in different context may have different meaning.
Currently it is impossible to tell if a user intentionally closed a notification by clicking on the "close" button or if "closeSnackbar" was invoked from somewhere in the application for whatever reason. Both will deliver reason "instructed".
This is my first contribution ever, so unsure If I'm doing everything correctly.