sweetalert2 11.4.6 → 11.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/SweetAlert.js CHANGED
@@ -228,6 +228,6 @@ Object.keys(instanceMethods).forEach((key) => {
228
228
 
229
229
  SweetAlert.DismissReason = DismissReason
230
230
 
231
- SweetAlert.version = '11.4.6'
231
+ SweetAlert.version = '11.4.7'
232
232
 
233
233
  export default SweetAlert
@@ -6,6 +6,7 @@ import { swalClasses } from '../utils/classes.js'
6
6
  import globalState, { restoreActiveElement } from '../globalState.js'
7
7
  import privateProps from '../privateProps.js'
8
8
  import privateMethods from '../privateMethods.js'
9
+ import { removeKeydownHandler } from '../keydown-handler.js'
9
10
 
10
11
  /*
11
12
  * Instance method to close sweetAlert
@@ -16,10 +17,7 @@ function removePopupAndResetState(instance, container, returnFocus, didClose) {
16
17
  triggerDidCloseAndDispose(instance, didClose)
17
18
  } else {
18
19
  restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose))
19
- globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
20
- capture: globalState.keydownListenerCapture,
21
- })
22
- globalState.keydownHandlerAdded = false
20
+ removeKeydownHandler(globalState)
23
21
  }
24
22
 
25
23
  const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
@@ -4,14 +4,17 @@ import { callIfFunction } from './utils/utils.js'
4
4
  import { clickConfirm } from './staticMethods/dom.js'
5
5
  import privateProps from './privateProps.js'
6
6
 
7
- export const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
7
+ export const removeKeydownHandler = (globalState) => {
8
8
  if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
9
9
  globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
10
10
  capture: globalState.keydownListenerCapture,
11
11
  })
12
12
  globalState.keydownHandlerAdded = false
13
13
  }
14
+ }
14
15
 
16
+ export const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
17
+ removeKeydownHandler(globalState)
15
18
  if (!innerParams.toast) {
16
19
  globalState.keydownHandler = (e) => keydownHandler(instance, e, dismissWith)
17
20
  globalState.keydownTarget = innerParams.keydownListenerCapture ? window : dom.getPopup()