aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorRohit Sharma <[email protected]>2020-11-20 19:06:24 +0530
committerGitHub <[email protected]>2020-11-20 15:36:24 +0200
commit0839cbf04dd9b94dc2f9806751660d921beb72e9 (patch)
treefc715f4af1107593013ae64808994a66a698ef56 /js/src
parent2630b05eb34c669d1771200b572efb09eb16c9f5 (diff)
downloadbootstrap-0839cbf04dd9b94dc2f9806751660d921beb72e9.tar.xz
bootstrap-0839cbf04dd9b94dc2f9806751660d921beb72e9.zip
Don't hide modal when keyboard is set to false in modal's configuration (#32179)
* Don't hide modal when config.keyboard is false * Update unit test - Modal should not be closed when pressing esc key if keyboard = false and backdrop is 'static' Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/src')
-rw-r--r--js/src/modal.js52
1 files changed, 26 insertions, 26 deletions
diff --git a/js/src/modal.js b/js/src/modal.js
index b220bfa94..4309cbd9a 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -365,7 +365,11 @@ class Modal {
return
}
- this._triggerBackdropTransition()
+ if (this._config.backdrop === 'static') {
+ this._triggerBackdropTransition()
+ } else {
+ this.hide()
+ }
})
if (animate) {
@@ -404,35 +408,31 @@ class Modal {
}
_triggerBackdropTransition() {
- if (this._config.backdrop === 'static') {
- const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
- if (hideEvent.defaultPrevented) {
- return
- }
+ const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
+ if (hideEvent.defaultPrevented) {
+ return
+ }
- const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
+ const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
+ if (!isModalOverflowing) {
+ this._element.style.overflowY = 'hidden'
+ }
+
+ this._element.classList.add(CLASS_NAME_STATIC)
+ const modalTransitionDuration = getTransitionDurationFromElement(this._dialog)
+ EventHandler.off(this._element, TRANSITION_END)
+ EventHandler.one(this._element, TRANSITION_END, () => {
+ this._element.classList.remove(CLASS_NAME_STATIC)
if (!isModalOverflowing) {
- this._element.style.overflowY = 'hidden'
+ EventHandler.one(this._element, TRANSITION_END, () => {
+ this._element.style.overflowY = ''
+ })
+ emulateTransitionEnd(this._element, modalTransitionDuration)
}
-
- this._element.classList.add(CLASS_NAME_STATIC)
- const modalTransitionDuration = getTransitionDurationFromElement(this._dialog)
- EventHandler.off(this._element, TRANSITION_END)
- EventHandler.one(this._element, TRANSITION_END, () => {
- this._element.classList.remove(CLASS_NAME_STATIC)
- if (!isModalOverflowing) {
- EventHandler.one(this._element, TRANSITION_END, () => {
- this._element.style.overflowY = ''
- })
- emulateTransitionEnd(this._element, modalTransitionDuration)
- }
- })
- emulateTransitionEnd(this._element, modalTransitionDuration)
- this._element.focus()
- } else {
- this.hide()
- }
+ })
+ emulateTransitionEnd(this._element, modalTransitionDuration)
+ this._element.focus()
}
// ----------------------------------------------------------------------