Skip to content

Commit

Permalink
Clear duration timeout after dismiss
Browse files Browse the repository at this point in the history
Fixes #4859
  • Loading branch information
svi3c authored May 29, 2017
1 parent 12d6e96 commit dfe6e0e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/snack-bar/snack-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export class MdSnackBar {
// If a dismiss timeout is provided, set up dismiss based on after the snackbar is opened.
if (config.duration > 0) {
snackBarRef.afterOpened().subscribe(() => {
setTimeout(() => snackBarRef.dismiss(), config.duration);
const timeoutHandle = setTimeout(() => snackBarRef.dismiss(), config.duration);
snackBarRef.afterDismissed().subscribe(() => {
clearTimeout(timeoutHandle);
});
});
}

Expand Down

0 comments on commit dfe6e0e

Please sign in to comment.