mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Fixed bug where previously focused element (document.activeElement) neede to be unfocused. Otherwise all key and focus events where performed on that element
This commit is contained in:
@@ -258,7 +258,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.clickToClose) {
|
if (this.clickToClose) {
|
||||||
window.addEventListener('keyup', this.onEscapeKeyUp)
|
// window.addEventListener('keyup', this.onEscapeKeyUp)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -268,7 +268,7 @@
|
|||||||
window.removeEventListener('resize', this.onWindowResize)
|
window.removeEventListener('resize', this.onWindowResize)
|
||||||
|
|
||||||
if (this.clickToClose) {
|
if (this.clickToClose) {
|
||||||
window.removeEventListener('keyup', this.onEscapeKeyUp)
|
// window.removeEventListener('keyup', this.onEscapeKeyUp)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -381,9 +381,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
onEscapeKeyUp (event) {
|
onEscapeKeyUp (event) {
|
||||||
if ((event.keyCode || event.which) === 27 && this.visible) {
|
// if (event.which === 27 && this.visible) {
|
||||||
this.$modal.hide(this.name)
|
// this.$modal.hide(this.name)
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
|
|
||||||
onWindowResize () {
|
onWindowResize () {
|
||||||
@@ -427,11 +427,20 @@
|
|||||||
toggle (state, params) {
|
toggle (state, params) {
|
||||||
const { reset, scrollable, visible } = this
|
const { reset, scrollable, visible } = this
|
||||||
|
|
||||||
|
console.log('woot')
|
||||||
|
|
||||||
const beforeEventName = visible
|
const beforeEventName = visible
|
||||||
? 'before-close'
|
? 'before-close'
|
||||||
: 'before-open'
|
: 'before-open'
|
||||||
|
|
||||||
if (beforeEventName === 'before-open') {
|
if (beforeEventName === 'before-open') {
|
||||||
|
/**
|
||||||
|
* Need to unfocus previously focused element, otherwise
|
||||||
|
* all keypress events (ESC press, for example) will trigger on that element.
|
||||||
|
*/
|
||||||
|
if (document.activeElement) {
|
||||||
|
document.activeElement.blur()
|
||||||
|
}
|
||||||
if (reset) {
|
if (reset) {
|
||||||
this.setInitialSize()
|
this.setInitialSize()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user