Skip to content

Commit

Permalink
Fix/notification message timeout (#201)
Browse files Browse the repository at this point in the history
* Fix: notification context binding

* Fix: don't use autobind

* Fix: Cancel timeout on hide to avoid event stacking
  • Loading branch information
Minh-Ng authored Jul 7, 2017
1 parent a26d600 commit 5d42af4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Notification {
this.notificationEl.focus();

// Hide notification automatically after a delay
setTimeout(this.hide, HIDE_TIMEOUT_MS);
this.timeout = setTimeout(this.hide.bind(this), HIDE_TIMEOUT_MS);
}

/**
Expand All @@ -65,6 +65,10 @@ class Notification {
* @return {void}
*/
hide() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
if (this.notificationEl) {
this.notificationEl.classList.add(CLASS_HIDDEN);
}
Expand Down

0 comments on commit 5d42af4

Please sign in to comment.