Description
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:
handleRequest() {
this.refs.snackbarRequesting.show();
this.setState({
requestLabel: 'Creating...',
disabled: true
});
setTimeout(() => {
this.setState({
requestLabel: 'Requested',
disabled: true
});
this.refs.snackbarRequested.show();
this.refs.snackbarRequesting.dismiss();
}, this.props.requestDelay);
}
render() {
return (
<Card>
<Button
disabled={this.state.disabled}
onClick={this.handleRequest}
primary
ref="create"
>
{this.state.requestLabel}
</Button>
<Snackbar message="Requesting..." ref="snackbarRequesting"/>
<Snackbar
autoHideDuration={1250}
message="Requested"
ref="snackbarRequested"
/>
</Card>
);
}
That second call to setState
causes the snackbarRequesting
state to revert back to open
because of the lines of code highlighted above, and since the operation has completed, the Snackbar will remain open.