diff options
| author | Johann-S <[email protected]> | 2018-07-25 11:29:16 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-02-20 22:05:45 +0200 |
| commit | c44db783bf17c907dd46f53fdaa917ec74ffbded (patch) | |
| tree | 69a380068b58961b01e5cd465e118dbda4d376dd /js/src/modal.js | |
| parent | cf821e1d4d1d67f6b4ce9651ae64c72a502c40ba (diff) | |
| download | bootstrap-c44db783bf17c907dd46f53fdaa917ec74ffbded.tar.xz bootstrap-c44db783bf17c907dd46f53fdaa917ec74ffbded.zip | |
chore(update): bump to 4.1.3
Diffstat (limited to 'js/src/modal.js')
| -rw-r--r-- | js/src/modal.js | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/js/src/modal.js b/js/src/modal.js index 34aa56606..8e56fc5b2 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -119,7 +119,7 @@ class Modal { relatedTarget }) - if (this._isShown || showEvent.isDefaultPrevented()) { + if (this._isShown || showEvent.defaultPrevented) { return } @@ -161,7 +161,7 @@ class Modal { const hideEvent = EventHandler.trigger(this._element, Event.HIDE) - if (!this._isShown || hideEvent.isDefaultPrevented()) { + if (!this._isShown || hideEvent.defaultPrevented) { return } @@ -282,16 +282,14 @@ class Modal { } _enforceFocus() { - if (this._isShown && this._config.keyboard) { - EventHandler.on(this._element, Event.KEYDOWN_DISMISS, (event) => { - if (event.which === ESCAPE_KEYCODE) { - event.preventDefault() - this.hide() - } - }) - } else if (!this._isShown) { - EventHandler.off(this._element, Event.KEYDOWN_DISMISS) - } + EventHandler.off(document, Event.FOCUSIN) // guard against infinite focus loop + EventHandler.on(document, Event.FOCUSIN, (event) => { + if (document !== event.target && + this._element !== event.target && + !this._element.contains(event.target)) { + this._element.focus() + } + }) } _setEscapeEvent() { @@ -383,7 +381,7 @@ class Modal { const backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop) EventHandler.one(this._backdrop, Util.TRANSITION_END, callback) - Util.emulateTransitionEnd(backdropTransitionDuration) + Util.emulateTransitionEnd(this._backdrop, backdropTransitionDuration) } else if (!this._isShown && this._backdrop) { this._backdrop.classList.remove(ClassName.SHOW) |
