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

Add snackbar callbacks for onShow and onDismiss with documentation #1390

Merged
merged 1 commit into from
Aug 13, 2015
Merged

Add snackbar callbacks for onShow and onDismiss with documentation #1390

merged 1 commit into from
Aug 13, 2015

Conversation

metalmatze
Copy link
Contributor

The material design guidelines say that there shouldn't be more than one snackbar at a time.
To implement this guideline I created a flux store with all messages. These messages are in a queue.

Making it work properly, I need to have the onShow() and onDismiss() callbacks on the snackbar.

hai-cea added a commit that referenced this pull request Aug 13, 2015
Add snackbar callbacks for onShow and onDismiss with documentation
@hai-cea hai-cea merged commit f17eeb8 into mui:master Aug 13, 2015
@hai-cea
Copy link
Member

hai-cea commented Aug 13, 2015

Thanks @metalmatze !

@metalmatze metalmatze deleted the feature/snackbar-events branch August 13, 2015 18:57
@rethink-rlinsalata
Copy link

Thanks for adding this, I was also trying to implement the "one snackbar at a time" guideline. However, I think to do it properly, the onDismiss() and onShow() callbacks need to occur after the CSS transitions finish.

The guideline says that the "When a second snackbar is triggered while the first is displayed, the first should start the contraction motion downwards before the second one animates upwards."
I was having trouble with my onDismiss being called too early, before the snackbar had actually closed. Thus, I was just updating the text without any noticeable actions.
Similarly, trying to check if there was an "active" snackbar by checking the .state.open was misleading, as the open state var changes immediately. Perhaps it needs another 'is hidden' variable? =/

Or, is there a better way to implement this "if (already open) close, then open" behavior?

@shaurya947
Copy link
Contributor

@rethink-rlinsalata take a look at #1668

@zannager zannager added the component: snackbar This is the name of the generic UI component, not the React module! label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: snackbar This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants