From 5d42af48568ceba46147e19f615cc499f433bdee Mon Sep 17 00:00:00 2001 From: MinhHNguyen Date: Fri, 7 Jul 2017 15:29:26 -0700 Subject: [PATCH] Fix/notification message timeout (#201) * Fix: notification context binding * Fix: don't use autobind * Fix: Cancel timeout on hide to avoid event stacking --- src/lib/Notification.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/Notification.js b/src/lib/Notification.js index 92a2ca183..2d10fd395 100644 --- a/src/lib/Notification.js +++ b/src/lib/Notification.js @@ -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); } /** @@ -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); }