Skip to content

Commit

Permalink
Merge pull request #4 from Gitsifu/vaban-ru
Browse files Browse the repository at this point in the history
fix:cannot read property 'contains' of undefined
  • Loading branch information
vaban-ru authored Aug 15, 2023
2 parents 82658e7 + f13a009 commit fb741a6
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/vue-bottom-sheet-vue2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,25 @@ export default {
document.documentElement.style.overscrollBehavior = 'none'
this.showSheet = true
this.$emit('opened')
}
},
keyupHandler(event){
const isFocused = (element) => document.activeElement === element
const isSheetElementFocused =
this.$refs.bottomSheet.contains(event.target) && isFocused(event.target)
if (event.key === 'Escape' && !isSheetElementFocused) {
this.close()
}
},
},
beforeDestroy() {
window.removeEventListener('keyup', this.keyupHandler)
},
async mounted() {
setTimeout(() =>{
this.initHeight()
const isFocused = (element) => document.activeElement === element
window.addEventListener('keyup', (event) => {
const isSheetElementFocused =
this.$refs.bottomSheet.contains(event.target) && isFocused(event.target)
if (event.key === 'Escape' && !isSheetElementFocused) {
this.close()
}
})
window.addEventListener('keyup', this.keyupHandler)
/**
* Create instances of Hammerjs
Expand Down

0 comments on commit fb741a6

Please sign in to comment.