1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-26 06:44:35 +02:00

Close modal with keyboard=true & backdrop=static (#29986)

* Close modal with keyboard=true & backdrop=static
This commit is contained in:
Giovanni Mendoza
2020-01-10 03:06:12 -06:00
committed by XhmikosR
parent 4e1fb4fe1a
commit 954a0b1e6a
3 changed files with 67 additions and 6 deletions

View File

@@ -306,9 +306,12 @@ class Modal {
}
_setEscapeEvent() {
if (this._isShown && this._config.keyboard) {
if (this._isShown) {
EventHandler.on(this._element, Event.KEYDOWN_DISMISS, event => {
if (event.which === ESCAPE_KEYCODE) {
if (this._config.keyboard && event.which === ESCAPE_KEYCODE) {
event.preventDefault()
this.hide()
} else if (!this._config.keyboard && event.which === ESCAPE_KEYCODE) {
this._triggerBackdropTransition()
}
})