1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-10-01 15:56:45 +02:00
Close modal with keyboard=true & backdrop=static
This commit is contained in:
Giovanni Mendoza
2020-01-10 11:06:12 +02:00
committed by XhmikosR
parent 0f0a8c364d
commit 6daae47cc0
3 changed files with 58 additions and 6 deletions

View File

@@ -325,9 +325,12 @@ class Modal {
}
_setEscapeEvent() {
if (this._isShown && this._config.keyboard) {
if (this._isShown) {
$(this._element).on(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()
}
})