Commit f530ab75 authored by Rohit Sharma's avatar Rohit Sharma Committed by XhmikosR
Browse files

Clear timeout before showing the toast (#31155)


* clear timeout before showing the toast

* Add unit test

* Remove the check for timeout

* Check for clearTimeout to have been called

Co-authored-by: default avatarXhmikosR <xhmikosr@gmail.com>
# Conflicts:
#	js/tests/unit/toast.spec.js
6 merge requests!36532My v4 dev,!34086v4: Fix prevented show event disables modals with fade class from being displayed again,!33729V4 dev,!33086V4 dev,!31901Add opacity utilities,!31513Update icons.md
Showing with 8 additions and 2 deletions
+8 -2
...@@ -83,6 +83,8 @@ class Toast { ...@@ -83,6 +83,8 @@ class Toast {
return return
} }
this._clearTimeout()
if (this._config.animation) { if (this._config.animation) {
this._element.classList.add(CLASS_NAME_FADE) this._element.classList.add(CLASS_NAME_FADE)
} }
...@@ -130,8 +132,7 @@ class Toast { ...@@ -130,8 +132,7 @@ class Toast {
} }
dispose() { dispose() {
clearTimeout(this._timeout) this._clearTimeout()
this._timeout = null
if (this._element.classList.contains(CLASS_NAME_SHOW)) { if (this._element.classList.contains(CLASS_NAME_SHOW)) {
this._element.classList.remove(CLASS_NAME_SHOW) this._element.classList.remove(CLASS_NAME_SHOW)
...@@ -184,6 +185,11 @@ class Toast { ...@@ -184,6 +185,11 @@ class Toast {
} }
} }
_clearTimeout() {
clearTimeout(this._timeout)
this._timeout = null
}
// Static // Static
static _jQueryInterface(config) { static _jQueryInterface(config) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment