Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions frontend/src/views/Shop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,16 @@ export default {
code: null,
}
},
beforeUnmount() {
document.removeEventListener('keydown', this.handleEscKey)
},
methods: {
openModal(product) {
this.product = product
this.modalOpen = true
// Remove first to prevent duplicate event listeners
document.removeEventListener('keydown', this.handleEscKey)
document.addEventListener('keydown', this.handleEscKey)
},
closeModal() {
this.product = null
Expand All @@ -246,6 +252,12 @@ export default {
this.purchaseSuccess = false
this.code = null
this.purchaseMode = 'myself'
document.removeEventListener('keydown', this.handleEscKey)
},
handleEscKey(event) {
if (event.key === 'Escape' && this.modalOpen) {
this.closeModal()
}
},
async purchase() {
this.loading = true
Expand Down
Loading