Skip to content

Commit

Permalink
fix: #285 close dialog doesnt work in electron
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Dec 27, 2016
1 parent 493ffbd commit 1781111
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/features/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function getPlatform () {
return browser
}

export default {
const Platform = {
is: getPlatform(),
has: {
touch: (() => !!('ontouchstart' in document.documentElement) || window.navigator.msMaxTouchPoints > 0)()
Expand All @@ -165,3 +165,6 @@ export default {
iframe: window.self !== window.top
}
}

Platform.has.popstate = !Platform.within.iframe && !Platform.is.electron
export default Platform
8 changes: 4 additions & 4 deletions src/vue-components/modal/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
this.__popstate = () => {
if (
!Platform.within.iframe &&
Platform.has.popstate &&
window.history.state &&
window.history.state.modalId &&
window.history.state.modalId >= this.__modalId
Expand All @@ -79,7 +79,7 @@ export default {
EscapeKey.pop()
this.active = false
if (!Platform.within.iframe) {
if (Platform.has.popstate) {
window.removeEventListener('popstate', this.__popstate)
}
Expand All @@ -103,7 +103,7 @@ export default {
this.active = true
this.__modalId = ++openedModalNumber
if (!Platform.within.iframe) {
if (Platform.has.popstate) {
window.history.pushState({modalId: this.__modalId}, '')
window.addEventListener('popstate', this.__popstate)
}
Expand All @@ -118,7 +118,7 @@ export default {
close (onClose) {
this.__onClose = onClose
if (Platform.within.iframe) {
if (!Platform.has.popstate) {
this.__popstate()
}
else {
Expand Down

0 comments on commit 1781111

Please sign in to comment.