-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Snackbar's get stuck open when receiving new props, regardless of nature #2018
Comments
@dlindahl Thanks for opening this issue. Regarding the logic of those line of code. The goal is to achieve the material spec stating that only one snackbar should be displayed at the same time. Regarding your example, I was expecting the Pure context mixin to prevent this, but was wrong since So, I think that you can use one Snackbar component to achieve the same with less logic on your application side. However, the logic you describe should first assert that we have new stuff to render. |
The changes in lines 93-113 of #1668 broke my usage of Snackbars. If the component receives new props while it is open, the Snackbar is closed, regardless of the nature of the new incoming props. And then, when the "
_oneAtTheTimeTimerId
" executes, the Snackbar opens, again regardless of what the current state is actually is.I have a component that reflects the state of an async operation that results in two Snackbars showing. Updating to 0.13.1 caused the first "Requesting..." Snackbar to reappear, and stay visible, even tho the prop changes do not relate at all to the Snackbars themselves.
Changing line 106 to
open: _this.props.openOnMount
seemed to work around the issue, but that whole block of code seems really odd to me, so I'm not sure that is the best solution.I tried to make a jsbin/jsfiddle/codepen example, but this project doesn't doesn't exist on a CDN nor does it have a distributable, so that ruled out anything quick. My click handler pseudo-code is as follows:
That second call to
setState
causes thesnackbarRequesting
state to revert back toopen
because of the lines of code highlighted above, and since the operation has completed, the Snackbar will remain open.The text was updated successfully, but these errors were encountered: