Skip to content

Commit

Permalink
fix: double-click in modal unexpectedly going back in browser history #…
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Oct 2, 2017
1 parent 0431c42 commit 0717372
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dev/components/components/modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<q-modal ref="layoutModal" :content-css="{minWidth: '80vw', minHeight: '80vh'}">
<q-modal-layout>
<q-toolbar slot="header">
<q-icon style="font-size: 500%" class="cursor-pointer" name="map" @click="closeMe" />
<q-btn flat @click="$refs.layoutModal.close()">
<q-icon name="keyboard_arrow_left" />
</q-btn>
Expand Down Expand Up @@ -146,6 +147,11 @@ export default {
this.$nextTick(() => {
this.$refs.positionModal.open()
})
},
closeMe () {
console.log('click')
this.$refs.layoutModal.close()
this.$refs.layoutModal.close()
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions src/components/modal/QModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export default {
},
data () {
return {
active: false
active: false,
toggleInProgress: false
}
},
computed: {
Expand Down Expand Up @@ -155,10 +156,11 @@ export default {
},
methods: {
open (onShow) {
if (this.active) {
if (this.active || this.toggleInProgress) {
return
}
this.toggleInProgress = true
const body = document.body
body.appendChild(this.$el)
Expand Down Expand Up @@ -199,6 +201,7 @@ export default {
if (typeof this.__onClose === 'function') {
this.__onClose()
}
this.toggleInProgress = false
this.__updateModel(false)
this.$emit('close')
}, duration)
Expand All @@ -225,15 +228,17 @@ export default {
if (typeof onShow === 'function') {
onShow()
}
this.toggleInProgress = false
this.__updateModel(true)
this.$emit('open')
}, duration)
},
close (onClose) {
if (!this.active) {
if (!this.active || this.toggleInProgress) {
return
}
this.toggleInProgress = true
this.__onClose = onClose
if (!Platform.has.popstate) {
Expand Down

0 comments on commit 0717372

Please sign in to comment.