Skip to content

Commit

Permalink
Clear timeout before showing the toast (#31155)
Browse files Browse the repository at this point in the history
* clear timeout before showing the toast

* Add unit test

* Remove the check for timeout

* Check for clearTimeout to have been called

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
# Conflicts:
#	js/tests/unit/toast.spec.js
  • Loading branch information
rohit2sharma95 authored and XhmikosR committed Jul 29, 2020
1 parent cc49a5b commit de0e1b5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions js/src/toast.js
Expand Up @@ -83,6 +83,8 @@ class Toast {
return
}

this._clearTimeout()

if (this._config.animation) {
this._element.classList.add(CLASS_NAME_FADE)
}
Expand Down Expand Up @@ -130,8 +132,7 @@ class Toast {
}

dispose() {
clearTimeout(this._timeout)
this._timeout = null
this._clearTimeout()

if (this._element.classList.contains(CLASS_NAME_SHOW)) {
this._element.classList.remove(CLASS_NAME_SHOW)
Expand Down Expand Up @@ -184,6 +185,11 @@ class Toast {
}
}

_clearTimeout() {
clearTimeout(this._timeout)
this._timeout = null
}

// Static

static _jQueryInterface(config) {
Expand Down

0 comments on commit de0e1b5

Please sign in to comment.